Indexing a numeric range in Solr

Does anyone know if it is possible to filter the index by a numerical range, for example, "1-5", "1", "2", "3", "4", "5"? I cannot find filter factories that do this.

Example: "1-5 ABC" is indexed as "1 ABC", "2 ABC", "3 ABC", "4 ABC", "5 ABC"

+4
source share
1 answer

What you want can be achieved for sure, but it can be easy.

One possible way to do this is without writing java code, perhaps using PatternReplaceFilter in your analysis chain. My regex expertise is very simple, so I can’t say for sure whether this is possible or not ... Your regular expression should be able to match and fix markers like "1-3" and then replace them with "1" ',' 2 ',' 3 '. But I doubt that this is possible, since you need to issue several tokens per match ...

The surefire way to achieve this is to write your own filterfactory class and process the logic there. It is possible, but requires java expertise.

+1
source

Source: https://habr.com/ru/post/1658137/


All Articles