ElasticSearch how best to prioritise results based on integer / keyword

I have a catalog of neoprene products that I would like to search. I'm interesting in how to achieve a search by thickness. Product names will contain the thickness along with a thickness field that contains the upper value, i.e. thickness:6mm

name: Rip Curl 6/5/4mm wetsuit
name: Rip Curl 3mm

Respective thickness properties

Thickness:6mm
Thickness:3mm

When a search is performed for 3mm I would like to prioritize all results that match exactly 3mm, before 4/3mm and 5/4/3mm etc.

Then when 4/3mm is searched I would like prioritize 4/3mm, 5/4/3mm and then 3mm.

The user may search in any of these terms, note that mm may be excluded.

5mm wetsuit
6/5/4mm wetsuit
4/5/6mm wetsuit
3 4mm wetsuit
3/4mm wetsuit
3-4mm wetsuit
3/4 wetsuit
3 4 wetsuit

I've thought about doing a keyword comparison on the 'thickness' field for the max int provided in the search. Then a text search for the other params.

Additionally, I've thought of parsing the data using a regex such as [\d\/m-]* (will select just the int ranges).

I could expand the product data out before inserting. So I would place each size in a keyword array but then I would still need to find the closest match and set a limit of what sort of matching is allowed. Maybe using something like the ngram_tokenizer

Please could someone advise how best to achieve this functionality and what tools would be best suited? I'm not after an example, more just to be pointed in the right direction.

Hi,

What you want is prioritize the exact match?
if so you can use "term" with a high boost inside a bool should with a "match" having lower boost so your document with exact match 3mm will be before the 3/4 mm, as both document will match.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

Hope it help.

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