Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to create an index in ES specifying a request body like below. Please find below my code :

import time
from elasticsearch import Elasticsearch
from elasticsearch import helpers
ELASTICSEARCH_HOST = "localhost"
ELASTICSEARCH_PORT = 9200
ELASTICSEARCH_INDEX_NAME = "phonetic_index"
es = Elasticsearch([{'host': ELASTICSEARCH_HOST, 'port': 
ELASTICSEARCH_PORT}])
if es.indices.exists(ELASTICSEARCH_INDEX_NAME):
  print("Deleting '%s' index..." % (ELASTICSEARCH_INDEX_NAME))
  res = es.indices.delete(index = ELASTICSEARCH_INDEX_NAME)
  print(" response: '%s'" % (res))
print("Creating '%s' index..." % (ELASTICSEARCH_INDEX_NAME))
request_body = {
  "settings": {
    "analysis": {
      "filter": {
        "haasephonetik": {
          "type": "phonetic",
          "encoder": "haasephonetik"
       "analyzer": {
        "haasephonetik": {
          "tokenizer": "standard",
          "filter": "haasephonetik"
   "mappings": {
    "type": {
       "properties": {
        "text": {
           "type": "text",
          "index": "not_analyzed",
           "fields": {
            "phonetic": {
               "type": "text",
              "analyzer": "haasephonetik"
res = es.indices.create(index = ELASTICSEARCH_INDEX_NAME, body 
request_body)
print(" response: '%s'" % (res))

The problem is that I have to following error that I canot convert the index as a boolean. So I don't understand why ther is the message in below. Anyone had already this error because it is not obvious for me

PUT http://localhost:9200/phonetic_index [status:400 
request:0.034s]
------------------------------------------------------------------ 
---------
RequestError                              Traceback (most recent 
call last)
<ipython-input-23-33349743a94c> in <module>()
----> 1 es.indices.create(index = ELASTICSEARCH_INDEX_NAME, body = 
request_body)
 ~/anaconda3/lib/python3.7/site- 
packages/elasticsearch/client/utils.py in _wrapped(*args, 
**kwargs)
     74                 if p in kwargs:
     75                     params[p] = kwargs.pop(p)
---> 76             return func(*args, params=params, **kwargs)
     77         return _wrapped
     78     return _wrapper
~/anaconda3/lib/python3.7/site- 
packages/elasticsearch/client/indices.py in create(self, index, 
body, params)
     86             raise ValueError("Empty value passed for a 
required argument 'index'.")
     87         return self.transport.perform_request('PUT', 
 _make_path(index),
 ---> 88             params=params, body=body)
     90     @query_params('allow_no_indices', 'expand_wildcards', 
'flat_settings',
~/anaconda3/lib/python3.7/site-packages/elasticsearch/transport.py 
in perform_request(self, method, url, headers, params, body)
    316                 delay = 2**attempt - 1
    317                 time.sleep(delay)
--> 318                 status, headers_response, data = 
connection.perform_request(method, url, params, body, 
headers=headers, ignore=ignore, timeout=timeout)
    320             except TransportError as e:
~/anaconda3/lib/python3.7/site- 
packages/elasticsearch/connection/http_urllib3.py in 
perform_request(self, method, url, params, body, timeout, ignore, 
headers)
    184         if not (200 <= response.status < 300) and 
response.status not in ignore:
    185             self.log_request_fail(method, full_url, url, 
body, duration, response.status, raw_data)
   --> 186             self._raise_error(response.status, raw_data)
       188         self.log_request_success(method, full_url, url, 
    body, response.status,
~/anaconda3/lib/python3.7/site- 
packages/elasticsearch/connection/base.py in _raise_error(self, 
status_code, raw_data)
    123             logger.warning('Undecodable raw error response 
from server: %s', err)
--> 125         raise HTTP_EXCEPTIONS.get(status_code, 
TransportError)(status_code, error_message, additional_info)
RequestError: RequestError(400, 'mapper_parsing_exception', 
'Failed to parse mapping [type]: Could not convert [text.index] to 
boolean')

Btw, thanks for your help.

Regards,

Billy

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.