"query": { "match_phrase": { "character": { "query": "谦虚 赞扬", "slop": 2 } } }, "track_total_hits": true } 3、multi_match multi_match 查询是 Elasticsearch 中一种用于在多个字段中搜索相同查询字符串的查询方式。它可以在多个字段之间执行相同的查询,并且可以指定不同字段之间的权重(boos...
match_phrase的特点: 词项匹配(查询分词的词项必须完全匹配到索引分词的词项中,并且词项的相对位置position必须一致) 分词后的相对位置也必须要精准匹配(slop) 使用slop之后,位置越近的得分就越高 短语查询和邻近查询都比简单的 query 查询代价更高 。 一个 match 查询仅仅是看词条是否存在于倒排索引中,而一个 match...
GET /_search{"query":{"match_phrase":{"message":{"query":"this is a test","analyzer":"my_analyzer"}}} zero terms query match_phrase也接受zero_terms_query为参数,使用方式和match查询语句相同 Match Phrase 前缀查询 match_phrase_prefix和match_phrase用法是一样的,区别就在于它允许对最后一个词条...
match_phrase,与match类似,但是索引分词和查询分词结果必须相同,包括分词得到的顺序,可配置参数slop,允许词和词之间出现其他token的数量。 本人在ik分词测试,需要将analyzer和search_quote_analyzer设置成一样的分词器,才能正确检索出结果。 match_phrase容易受到停用的影响,不配置ik的停用词影响match搜索,配置之后影响match...
{“from”: 0,“size”: 10,“query”: {“bool”: {“must”: [{“term”: {“userPlace”: {“value”: “吉林”,“boost”: 1.0}}},{“match_phrase”: {“userName”: {“query”: “测试”,//入参只要被测试人员包含即可“slop”: 0,“zero_terms_query”: “NONE”,“boost”: 1.0...
match_phrase_prefix 和 match_phrase 类似,只不过 match_phrase_prefix 支持最后一个 term 的前缀匹配。 # 新增文档 PUT /test_idx/_doc/4 { "desc":"lifeabc is what" } PUT /test_idx/_doc/5 { "desc":"asdflifeabc is what" } # 前缀查询 ...
此外,match_phrase查询还有一个slop参数,可以定义词组中的词语可能存在的位置偏移量。例如,如果将slop设置为 1,则查询 "this is a test" 也可匹配 "this is test a",因为 "a" 和 "test" 只需移动一个位置即可匹配。 代码语言:javascript 代码运行次数:0 ...
match_phrase与slop一起用,能保证分词间的邻近关系,slop参数告诉match_phrase查询词条能够相隔多远时仍然将文档视为匹配,默认是0。为0时 必须相邻才能被检索出来。 例如下面的语句,会把“白雪公主吃苹果”也能检索出来 GET my_index/_search { "query": { ...
"match_phrase":{ "productName":{ "query":"我爱我家", "slop":"1" } } } } 项目中遇到搜索不到数据的解决方式 如果出现搜索不出来数据 但是没有 按上面规则来进行判断 1.首先看搜索不出来的文档的分词规则 2.然后测试搜索分词跟他是否一致 ...
POST /my_index/my_type/_search { "query": { "match_phrase": { "title": { "query": "quick dog", "slop": 50} } } } 注意高slop值。 { "hits": [ { "_id": "3", "_score": 0.75, "_source": { "title": "The quick brown fox jumps over the quick dog" } }, { "_id...