Hello!
I'm trying to build a search engine to an e-commerce but failing to get the relevance I need. I've read tutorials all over the internet but could not manage to implement the way it fits this special case needs.
First, let me explain how to I want it to work: as the user type I want to have relevant suggestions of products based on the user query.
I actually happen to have a perfect example of it working the way I wanted (and with a little extra). This is how I want it to work (minus the suggestion which is not needed):
And when I type in "furad bosc" it still finds the results as shown bellow:
The index I have so far looks like this:
{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 3,
"max_gram": 25
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter",
"asciifolding"
]
}
}
}
},
"mappings": {
"products": {
"properties": {
"name": {"type": "text", "analyzer": "autocomplete", "search_analyzer": "standard"},
"description": {"type": "text"},
"price": {"type": "double"},
"product_id": {"type": "integer"},
"image": {"type": "text"},
"quantity": {"type": "integer"},
"width": {"type": "float"},
"length": {"type": "float"},
"height": {"type": "float"},
"weight": {"type": "float"},
"model": {"type": "text"},
"name_suggester": {"type": "completion", "analyzer": "autocomplete"}
}
}
}
}
Disclaimer: the other fields (weight, width...) are for future implementations.
As for searching, I have used multiple combination of queries, the closest I got to the desired result is this one:
{
"query": {
"bool": {
"should": [
{"match_phrase_prefix": {"name^25": "furadeira bosch"} },
{"term": {"name^2": "furadeira bosch"} }
],
"must": {
"query_string": {
"query" : "furadeira bosch",
"fields" : [
"name^18",
"model",
"manufacturer^10"
]
}
}
}
}
}
But the results I get fail in scoring the way I wanted to:
Now is when I ask. What am I doing wrong and how do I calculate the score correctly?
PS: I'm sorry for the bad english