elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'No handler for type [string] declared on field [texts]')
this
'index': 'analyzed' OR 'index': 'not_analyzed'
is an older elasticsearch version mapping and not needed.
All you need to do is use 'text' for analyzed string fields and 'keyword' for not_analyzed text fields, like this:
es = Elasticsearch("localhost:9200")
request_body = {
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
'mappings': {
'examplecase': {
'properties': {
'tbl_id': {'type': 'keyword'},
'texts': {'type': 'text'},
}
}
}
}
es.indices.create(index='example_index', body=request_body)
see reference in Elastic docs here: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
littlely
Updated on June 27, 2022Comments
-
littlely almost 2 years
I use elasticsearch python api to create mappings, but it went some wrong:
es = Elasticsearch("localhost:9200") request_body = { "settings": { "number_of_shards": 5, "number_of_replicas": 1 }, 'mappings': { 'examplecase': { 'properties': { 'tbl_id': {'index': 'not_analyzed', 'type': 'string'}, 'texts': {'index': 'analyzed', 'type': 'string'}, } } } } es.indices.create(index='example_index', body=request_body)
it shows
elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'No handler for type [string] declared on field [texts]')
, and I find some solution that they say: usetext
instead ofstring
in the field type, but it also went wrong:elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Failed to parse mapping [examplecase]: Could not convert [texts.index] to boolean'). The elasticsearch version is
elasticsearch-6.5.4. How can I deal with it?