Reputation: 524
I am learning ElasticSearch using the 5.1 version. I have an index "mycontent" and a type "simpledocument". I am running into an error "illegal_argument_exception no mapping found for field" while trying to check the suggest/completion feature on the simpledocument type. The details are below:
GET _search
{
"suggest":{
"my-suggestion":{
"prefix":"ap",
"completion":{
"field":"suggest"
}
}
}
}
This gives me the response:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 5,
"failed": 1,
"failures": [
{
"shard": 0,
"index": ".kibana",
"reason": {
"type": "illegal_argument_exception",
"reason": "no mapping found for field [suggest]"
}
}
]
},
......
The mapping does have the suggest field in it:
GET _mapping/simpledocument
{
"mycontent": {
"mappings": {
"simpledocument": {
"properties": {
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "integer"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"path": {
"type": "keyword"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
},
"tags": {
"type": "keyword"
}
}
}
}
}
}
Here is a sample document:
GET mycontent/simpledocument/7
{
"_index": "mycontent",
"_type": "simpledocument",
"_id": "7",
"_version": 1,
"found": true,
"_source": {
"name": "Suggested Document",
"description": "this document does not contain a lot of content. Mainly used to test the suggest feature.",
"tags": [
"suggest",
"document"
],
"suggest": [
"and",
"design",
"api"
]
}
}
Can somebody please help me figure out my mistake? Why does it say "no mapping found" when the mapping is there?
Upvotes: 0
Views: 8437
Reputation: 14217
GET _search
will search all index, as the error, it's saying the index .kibana
doesn't have the suggest
field, as your GET _mapping/simpledocument
, the suggest field should only exist in simpedocument
index type.
so maybe you need to do it like:
GET mycontent/simpledocument/_search
{
"suggest":{
"my-suggestion":{
"prefix":"ap",
"completion":{
"field":"suggest"
}
}
}
}
Upvotes: 8