我对弹性搜索查询有疑问:
我有两个文档,内容字段使用标准分析器,值为:
"内容":"但巴菲特在富国银行的股份,以及约翰逊热门在其他一些主要银行的股份&#34
"内容":" Taco Bell的主要信息约翰逊热 Fancher告诉Nation的餐厅新闻,手机是他们的主要现在关注"
当我使用匹配查询时,我可以获得这两个文档:
localhost:9200/content/en-us/_search?pretty=true -d '
{
"query" : {
"match" : {
"content" : "johnson hot"
}
}
}'
但是我无法使用更像查询的方式:
localhost:9200/content/en-us/_search?pretty=true -d '
{
"from": 0,
"size": 200,
"query": {
"more_like_this_field": {
"content": {
"like_text": "johnson hot",
"min_term_freq": 1,
"max_query_terms": 12
}
}
}
}'
结果:
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
有人知道为什么吗? 是否更类似于"类似"在SQL?
由于 约翰逊
答案 0 :(得分:0)
更像是这个字段查询会通过匹配指定字段的内容为您提供类似的文档。
您必须将 min_doc_freq 设置为1.默认值为5,因此它会忽略 like_text中的条件它们不会出现超过5个文档。由于您只有两个文档,因此将忽略术语 jhonson 和 hot 。以下查询将起作用
curl 'http://localhost:9200/content/en-us/_search?pretty=true' -d '{
"from": 0,
"size": 200,
"query": {
"more_like_this_field": {
"content": {
"like_text": "johnson hot",
"min_term_freq": 1,
"max_query_terms": 12,
"min_doc_freq": 1
}
}
}
}'