没有命中的Elasticsearch msearch查询

时间:2016-12-23 07:41:46

标签: elasticsearch

我是Elastic 5.1的新手,(一般是弹性新手),我有一个列表,我使用msearch发送到弹性。

但是以下内容不会返回任何匹配,但索引中的文档如下所示:

max3 :: Ord a => a -> a -> a -> a   
max3 a b = max a . max b

}

这是发送给msearch的正文

{
"_index": "all_items",
"_type": "product",
"_id": "1000002007900",
"_version": 2,
"found": true,
"_source": {
    "doc": {
        "title": "title here",
        "brand": null,
        "updatedOn": "2016-12-22T14:00:26.016290",
        "price": 49,
        "viewed7": 0,
        "idInShop": "11",
        "active": true,
        "model": null,
        "_id": 1000002007900,
        "purchased7": 0
    },
    "doc_as_upsert": true
}

如果我只发送[ { "index": "all_items", "type": "product" }, { "sort": [ { "_score": "desc" } ], "query": { "function_score": { "query": { "bool": { "filter": [ { "term": { "active": true } } ], "should": [], "must_not": [], "must": [] } }, "functions": [ { "script_score": { "script": { "lang": "painless", "inline": "_score * params.constant * (doc['discountPrice'] > 0 ? doc['price'] / doc['discountPrice'] : 0)", "params": { "constant": 1.2 } } } } ], "score_mode": "multiply" } }, "from": 0, "size": 3 } ,我会受到点击。

1 个答案:

答案 0 :(得分:0)

您可以使用match query来获得所需的结果。

o

您可以在link了解有关[ { "index": "all_items", "type": "product" }, { "sort": [ { "_score": "desc" } ], "query": { "function_score": { "query": { "match": { "active": true } }, "functions": [ { "script_score": { "script": { "lang": "painless", "inline": "_score * params.constant * (doc['discountPrice'] > 0 ? doc['price'] / doc['discountPrice'] : 0)", "params": { "constant": 1.2 } } } } ], "score_mode": "multiply" } }, "from": 0, "size": 3 } ] match query(您使用过的)的更多信息。