Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No handler for type [text] declared on field [title] (python elasticsearch

all. The python elasticsearch version I used is

import elasticsearch
print elasticsearch.__version__
(5, 0, 1)

the mappings is

request_body = {
    'mappings':{
        'post': {
            'properties': {
                'title': {
                    'type': 'text',
                }
            }
        }
    }
}

The error is :

{u'status': 400, u'error': {u'caused_by': {u'reason': u'No handler for type [text] declared on field [title]', u'type': u'mapper_parsing_exception'}, u'root_cause': [{u'reason': u'No handler for type [text] declared on field [title]', u'type': u'mapper_parsing_exception'}], u'type': u'mapper_parsing_exception', u'reason': u'Failed to parse mapping [post]: No handler for type [text] declared on field [title]'}}

Why es 5.0 can not recognize the "text" type? What's wrong with my setup? Thanks a lot!

like image 511
chocolate9624 Avatar asked Jan 15 '17 07:01

chocolate9624


2 Answers

There are a couple of issues in your mapping. Replace all the single quotes with double quotes and remove the , after the last line(field type definition.)

    {  
      "mappings":{  
        "post":{  
          "properties":{  
            "title":{  
              "type":"text"
            }
          }
        }
      }
    }
like image 101
Ravi Naik Avatar answered Sep 29 '22 07:09

Ravi Naik


analyzer is mandatory for type:text. Refer https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html

like image 30
Balaji Katika Avatar answered Sep 29 '22 07:09

Balaji Katika