小编Dav*_*and的帖子

Elasticsearch更像是使用like_text的查询

我对使用更像这个查询感到沮丧.

这是我的索引创建:

curl -XPUT 'http://127.0.0.1:9200/food/' -d 
'{
  "mappings": {
    "fruit": {
      "properties": {
        "term": {
          "type": "string",
          "term_vector": "yes"
        }
      }
    }
  }
}'
Run Code Online (Sandbox Code Playgroud)

这是该索引中的一个示例数据:

{
  "_index": "food",
  "_type": "fruit",
  "_id": "2",
  "_score": 1,
  "_source": {
    "term": "yellow",
    "property_ids": [
      1
    ],
    "id": 2
  }
}
Run Code Online (Sandbox Code Playgroud)

最后这里更像是我用来对它尝试返回数据的查询:

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
    }
  }
}
'
Run Code Online (Sandbox Code Playgroud)

问题是,当我进行此搜索时,我得不到任何结果:

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}%
Run Code Online (Sandbox Code Playgroud)

如果我只为"黄色"执行标准通配符查询,我会得到该结果.我错过了什么?

elasticsearch

3
推荐指数
1
解决办法
1926
查看次数

标签 统计

elasticsearch ×1