I'm sorry if this has already been answered but I couldn't find it anywhere.
I'm currently working on a product search engine for a customer.
Right now I'm on a pretty good spot but there is one thing I would like to improve.
Here's the query I'm currently using: https://pastebin.com/F81HbYud (I'm sorry if this is an awful query, I'm not really an expert with the Query DSL)
So this matches documents with a name containing "choco" but not "chocolat".
The problem is that I'm not sure how to do that without having to invest a considerable amout of work splitting the string to add a wild car to every word. I should add that obviously Elasticsearch is not exposed in full frontal and that I'm using the PHP client. My PHP code is just answering and Ajax request.
My goal would be to improve things in such way that perfect matches are shown first, then matches with only n perfect word match, then partial matches.
If the search string was: "pain au chocolat"
I would like products with "pain au chocolat" in their name to get the highest score.
Then the products with either "pain" or "chocolat".
Then products with partial matches like "chocolatine".
I tried several approaches but I'm not exactly an expert with the query DSL so I can't really figure out how to do this properly.
Could anyone give me an idea please? Thanks a lot!