Suggester completion with short product model names

Hi,

We're building a database with various technological products, and trying to use the completion suggester to build an autocomplete search bar.

This is built inside Invision Community, so we're using the same index as the rest of the community content, and for that reason the maximum version we can use is 6.8.

The problem we're facing is with mobile phones with model names such as "Samsung Galaxy S7". If I search for "galaxy s", I'm getting results for "Samsung Galaxy A6". If I search for "galaxy s8", I'm getting "Samsung Galaxy S7", even though the S8 as well as S9 exists in our database.

PUT /test
{
	"mappings": {
		"content": {
			"properties": {
				"index_title": {
					"type": "text"
				},
				"index_title_completion": {
					"type": "completion",
					"analyzer": "standard"
				}
			}
		}
	}
}

PUT /test/content/1
{
	"index_title": "Samsung Galaxy A6",
	"index_title_completion": {
		"weight": 2019,
		"input": [
			"Samsung Galaxy A6",
			"Galaxy A6",
			"A6"
		]
	}
}

PUT /test/content/2
{
	"index_title": "Samsung Galaxy S7",
	"index_title_completion": {
		"weight": 2019,
		"input": [
			"Samsung Galaxy S7",
			"Galaxy S7",
			"S7"
		]
	}
}

PUT /test/content/3
{
	"index_title": "Samsung Galaxy S8",
	"index_title_completion": {
		"weight": 2019,
		"input": [
			"Samsung Galaxy S8",
			"Galaxy S8",
			"S8"
		]
	}
}

PUT /test/content/4
{
	"index_title": "Samsung Galaxy S9",
	"index_title_completion": {
		"weight": 2019,
		"input": [
			"Samsung Galaxy S9",
			"Galaxy S9",
			"S9"
		]
	}
}

With this search I'm expecting to see one of the "S" models

GET /test/content/_search
{
	"suggest": {
		"autocomplete": {
			"prefix": "galaxy s",
			"completion": {
				"field": "index_title_completion",
				"fuzzy": {
					"fuzziness": 1
				}
			}
		}
	}
}

But what I am getting is the A6.

GET /test/content/_search
{
	"suggest": {
		"autocomplete": {
			"prefix": "galaxy s9",
			"completion": {
				"field": "index_title_completion",
				"fuzzy": {
					"fuzziness": 1
				}
			}
		}
	}
}

And with this I'm getting the S7, instead of the S9 which does exist in the index.

The weight I've put in is the year the product was released. Thinking that might be a good way to get the most popular products to show up first in the search.

I did notice when writing this post that removing the "fuzziness" option will get me the proper results, but I would appreciate it if I can solve this and still keep the fuzziness.

Thanks

Given the fact, that suggesters are pretty fast, how about just sending two suggest queries and decide based on the data being returned, which result to use?

2 Likes

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