我对使用更像这个查询感到沮丧。
这是我的索引创建:
curl -XPUT 'http://127.0.0.1:9200/food/' -d
'{
"mappings": {
"fruit": {
"properties": {
"term": {
"type": "string",
"term_vector": "yes"
}
}
}
}
}'
以下是该索引中的一段数据示例:
{
"_index": "food",
"_type": "fruit",
"_id": "2",
"_score": 1,
"_source": {
"term": "yellow",
"property_ids": [
1
],
"id": 2
}
}
最后这里更像是我用来对它尝试返回数据的查询:
curl -XGET 'http://127.0.0.1:9200/food/_search' -d '{
"query": {
"more_like_this": {
"fields": [
"term"
],
"like_text": "yellow",
"min_term_freq": 1,
"max_query_terms": 12
}
}
}
'
问题是当我进行此搜索时,我得不到任何结果:
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}%
如果我只对“黄色”执行标准通配符查询,我会得到该结果。我错过了什么?
答案 0 :(得分:7)
默认情况下,min_doc_freq
为5(check doc)因此,您的查询无效,因为您的索引不包含至少5个term
属性保留{{1}的文档}}。因此,在查询中将yellow
设置为1,它应该可以正常工作。例如:
min_doc_freq