简体   繁体   English

多场弹性搜索中的完成建议

[英]Completion Suggester in elasticsearch in mutifield

I'm using elasticsearch for the first time. 我第一次使用elasticsearch。 I'm trying to use completion suggester in multi-field key, although I don't see any error but I don't get the response. 我正在尝试在多字段键中使用完成建议程序,尽管我没有看到任何错误,但没有得到响应。

Mapping creation: 映射创建:

PUT /products5/
{
  "mappings":{
    "products" : {
      "properties" : {
        "name" : {
          "type":"text",
          "fields":{
               "text":{
                    "type":"keyword"
                    },
              "suggest":{  
                  "type" : "completion"
              }
          }
        }
      }
    }

  }
} 

Indexing: 索引:

PUT /products5/product/1
{
  "name": "Apple iphone 5"

}
PUT /products5/product/2
{
  "name": "iphone 4 16GB"


}
PUT /products5/product/3
{
  "name": "iphone 3 SS 16GB black"


}
PUT /products5/product/4
{
  "name": "Apple iphone 4 S 16 GB white"


}
PUT /products5/product/5
{ 
  "name": "Apple iphone case"

}

Query: 查询:

POST /products5/product/_search
{
  "suggest":{
    "my-suggestion":{
      "prefix":"i",
      "completion":{
        "field":"name.suggest"
      }
    }
  }

}

Output: 输出:

   {
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": 0,
    "hits": []
  },
  "suggest": {
    "my-suggestion": [
      {
        "text": "i",
        "offset": 0,
        "length": 1,
        "options": []
      }
    ]
  }
}

Please guide me what is the mistake, I tried every possible options. 请指导我这是什么错误,我尝试了所有可能的选择。

From the first perspective this looks accurate. 从第一个角度看,这看起来很准确。 Probably the reason why you don't have correct response is that you added documents in the index before you created mapping in the index. 可能没有正确响应的原因是,在索引中创建映射之前,已在索引中添加了文档。 And documents are not indexed according to the mapping you specified 并且未根据您指定的映射对文档建立索引

I have found an issue in your mapping name. 我在您的映射名称中发现了一个问题。 There is an inconsistency between name of the mapping and value which you specifies in the url when you're creating new documents. 创建新文档时,映射名称与您在url中指定的值之间存在不一致。 You create a mapping in the index with the name products . 您在索引中使用名称products创建一个映射。 And when you add new documents you're specifying product as a name of the mapping of your index and it doesn't end with s . 当您添加新文档时,您要指定product作为索引映射的名称,并且不以s结尾。 You have a typo. 你有错字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch完成建议者Spring MVC - Elasticsearch for completion suggester spring mvc 使用Java API的ElasticSearch完成建议器 - ElasticSearch completion suggester with Java API Elasticsearch:将`slop`参数与完成提示器一起使用 - Elasticsearch: Use `slop` parameter with Completion Suggester 使用Java REST Client API在Elasticsearch 6.5.4中完成建议 - Completion Suggester in Elasticsearch 6.5.4 with Java REST Client API 在spring-data-elasticsearch中是否可以使用Context Recommendationer映射Completion字段? - Is it possible to map Completion field with Context Suggester in spring-data-elasticsearch? 是否可以使用Spring的注释为Elasticsearch中的映射定义Completion Suggester? - Is it possible to use Spring's annotations to define Completion Suggester for a mapping in Elasticsearch? ElasticSeach Auto Complete 使用完成建议器返回完整文档 - ElasticSeach Auto Complete using Completion suggester to Return the Complete Document Elasticsearch完成建议不区分大小写 - Elasticsearch completion suggestion case insensitive Elasticsearch-在Java中实现完成建议(API版本5!) - Elasticsearch - Implement Completion Suggestion in Java (API Version 5!) 通过查询更新Elasticsearch Java客户端并等待完成 - Elasticsearch java client update by query with wait for completion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM