ElasticSearch :: Исключение при создании индекса и документа - PullRequest
0 голосов
/ 24 августа 2018

Я новичок в ElasticSearch и пытался выполнить пример, упомянутый на их домашней странице, где я наткнулся на этот erorr -

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "unknown setting [index.mappings.employee.properties.age.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "unknown setting [index.mappings.employee.properties.age.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings",
        "suppressed": [
            {
                "type": "illegal_argument_exception",
                "reason": "unknown setting [index.mappings.employee.properties.experience.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
            },
            {
                "type": "illegal_argument_exception",
                "reason": "unknown setting [index.mappings.employee.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
            },
            {
                "type": "illegal_argument_exception",
                "reason": "unknown setting [index.mappings.employee.properties.name.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
            }
        ]
    },
    "status": 400
}

URL-адрес и тело запроса на публикацию выглядят следующим образом -

URL -> http://localhost:9200/company ТЕЛО ->

{
  "settings": {
    "index": {
       "number_of_shards": 1,
       "number_of_replicas": 1
    },
    "analysis": {
      "analyzer": {
        "analyzer-name": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": "lowercase"
        }
      }
    },
    "mappings": {
      "employee": {
        "properties": {
          "age": {
            "type": "long"
          },
          "experience": {
            "type": "long"      
          },
          "name": {
            "type": "string",
            "analyzer": "analyzer-name"
          }
        }
      }
    }
  }  
}

Как исправить ошибку?

Ответы [ 2 ]

0 голосов
/ 24 августа 2018
As you mentioned that you are new to Elastic Search, better start with the basic and use the default settings of ElasticSearch. Use the following mapping:

curl -XPUT localhost:9200/company -d '{
    "mappings": {
        "employee": {
            "properties": {
                "age": {"type": "long"},
                "experience": {"type": "long"},
                "name": {"type": "string","index": "not_analyzed"}
            }
        }
    }
}'
0 голосов
/ 24 августа 2018

В синтаксисе вашего объекта тела JSON есть две ошибки:

  1. Узел settings должен иметь только двух дочерних элементов: index и analysis.Узел mappings должен быть корневого уровня.
  2. Поле name имеет недопустимый тип string, оно должно быть text или keyword.Поскольку вам необходимо проанализировать это поле, оно должно быть text в вашем случае.

Таким образом, рабочий запрос должен выглядеть следующим образом:

{
  "settings": {
    "index": {
       "number_of_shards": 1,
       "number_of_replicas": 1
    },
    "analysis": {
      "analyzer": {
        "analyzer-name": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": "lowercase"
        }
      }
    }
  },
  "mappings": {
    "employee": {
      "properties": {
        "age": {
          "type": "long"
        },
        "experience": {
          "type": "long"      
        },
        "name": {
          "type": "text",
          "analyzer": "analyzer-name"
        }
      }
    }
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...