query 查询: 模糊匹配,并对匹配出来的数据进行评分。
constant_score: 固定分数。
filter: 查询: (query 属于类似就可以查出来,而 filter 类似 = 符号,要么成功,要么失败,没有中间值,查询速度比较快)
GET 127.0.0.1:9200/shop-index/_search { "query": { "match_all": {}} }
{ "query": { "match": {"title": "串"} }, "from": 10, "size": 10 }
{ "query": { "match": {"title": "串"} }, "sort": [ {"id": {"order": "desc" }} ], "from": 10, "size": 10 }
mutil_match 查询:“query”: “串串”, 为要查寻的关键字,“fields”: [ “title”, “tag”] 从 title 和 tag 属性中去找。有一个匹配就算成功。
{ "query": { "multi_match": { "query": "串串", "fields": [ "title", "tag"] } } }
query_string 语法查询: “query”: “(关键字 and 关键字) or 关键字” 各种关键字 全局搜索
{ "query": { "query_string": { "query": "(水煮肉 and 回锅肉) or 西葫芦" } } }
query_string 可以限定 查询字段(默认查询所有字段)
{ "query": { "query_string": { "query": "(水煮肉 and 回锅肉) or 西葫芦", "fields": ["title" ] } } }
filter 查询:
{"query": { "bool": { "filter": { "term": {"id": "13"} } } } }
{ "query": { "constant_score": { "filter": { "match": { "title": "火锅" } }, "boost": 2 } } }
{ "query": { "bool": { "must": [ { "match": { "title": "火锅" } }, { "match": { "tag": "串串" } } ] } } }
should 语法查询
{ "query": { "bool": { "should": [ { "match": { "title": "串串" } }, { "match": { "tag": "西葫芦" } } ] } } }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/215860.html原文链接:https://javaforall.net
