4

Does anyone know if it's possible to filter index a numeric range such as "1-5" to be "1","2","3","4","5"? I can't find any filter factories that does this.

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

GucciProgrammer
  • 181
  • 2
  • 4
  • 13
  • Could you clarify what exactly you are trying to do? Just trying to get my head around your question. Are you looking to filter your search results based on a range in the ID? – Lefty G Balogh Oct 19 '16 at 11:42
  • @LeftyGBalogh Filter by search result is easy to do but what I need is to have a filter factory which indexes my document of say "1-5 A" to be "1 A","2 A","3 A","4 A","5 A" so when I do a search of "3 A", I get the result of document "1-5 A" – GucciProgrammer Oct 19 '16 at 17:57

1 Answers1

1

What you want can be achieved for sure, but it might not be straightforward.

One possible way of doing it without writing java code, might by using PatternReplaceFilter in your analysis chain. My regex expertise is very basic, so I am not able to say for sure if it is possible or not...Your regex should be able to match and capture the '1-3' type tokens, and then replace them with '1', '2', '3'. But I doubt it's possible to do this, as you need to emit several tokens per match...

The sure way to achieve this is to write your custom filterfactory class, and handle the logic there. This is possible but requires java expertise.

Community
  • 1
  • 1
Persimmonium
  • 15,593
  • 11
  • 47
  • 78