首页 > 解决方案 > 创建后elasticsearch映射为空

问题描述

我正在尝试使用 search_as_you_type 数据类型为我的弹性搜索创建一个自动完成索引。我运行的第一个命令是

curl --request PUT 'https://elasticsearch.company.me/autocomplete' \
 '{
   "mappings": {
       "properties": {
           "company_name": {
               "type": "search_as_you_type"
           },
           "serviceTitle": {
               "type": "search_as_you_type"
           }
       }
   }
}'

返回

{"acknowledged":true,"shards_acknowledged":true,"index":"autocomplete"}curl: (3) nested brace in URL position 18:
{
   "mappings": {
       "properties": etc.the rest of the json object I created}}

然后我重新索引使用

curl --silent --request POST 'http://elasticsearch.company.me/_reindex?pretty' --data-raw '{
 "source": {
   "index": "existing_index"
 },
 "dest": {
   "index": "autocomplete"
 }
}' | grep "total\|created\|failures"

我希望看到一些"total":1000,"created":5等,但从终端得到某种响应,但我什么也没得到。此外,当我检查我的自动完成索引的映射时,通过运行curl -u thething 'https://elasticsearch.company.me/autocomplete/_mappings?pretty',我得到一个空的映射结果:

{
  "autocomplete" : {
    "mappings" : { }
  }
}

我在创建索引或重新索引时出错了吗?我期待自动完成映射显示我正在搜索的两个字段,即:“company_name”和“serviceTitle”。任何想法如何解决?

标签: elasticsearchautocomplete

解决方案


推荐阅读