Elasticsearch complete suggestion is showing only half sentence, why?


(radhe) #1

Mapping:

PUT movies
{
"mappings": {
"marvels": {
"properties": {
"name": {
"type": "completion"
},
"year": {
"type": "keyword"
}
}
}
}
}

Indexing data:

POST movies/marvels
{
"name": {
"input": [
"Captain America: The First Avenger",
"America: The First Avenger",
"The First Avenger",
"First Avenger",
"Avenger"
]
},
"year": "2011"
}

Suggester:

GET movies/marvels/_search
{
"suggest": {
"movie-suggest-fuzzy": {
"prefix": "first avengar",
"completion": {
"field": "name",
"fuzzy": {
"fuzziness": 1
}
}
}
}
}

Result:

"suggest": {
"movie-suggest-fuzzy": [
{
"text": "first avengar",
"offset": 0,
"length": 13,
"options": [
{
"text": "First Avenger",
"_index": "movies",
"_type": "marvels",
"_id": "EbqgEmQBRGMJ9q2gdjM3",
"_score": 11,
"_source": {
"name": {
"input": [
"Captain America: The First Avenger",
"America: The First Avenger",
"The First Avenger",
"First Avenger",
"Avenger"
]
}
}
}
]
}
]
}

The problem is I want to show "Captain America: The First Avenger" as suggestion but it only shows "First Avenger". What to do?


(radhe) #2

Anyone?


(radhe) #3

Someone?


(radhe) #4

No one?


(radhe) #5

Someone?


#6

Completion suggester uses prefixes. The only way you're going to get "Captain America: The First Avenger" as a suggestion is to pass in something starting with C.


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.