0

I need a token filter chain for these filter rules: * Remove all stopwords * If the token list is now empty, then restore the stop words

Reason: I have to find, for example, the book "It" by Steven King.

Any guidance help very much appreciated.

1 Answers1

0

Use a synonym filter to change it to _it_ for example: it => _it_ and at searching time you use an analyzer that uses the same synonym filter.

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
  • But with this solution I'll got the "it" from "How it Works Annual" in my index. Right? – M. Woelfel Apr 20 '17 at 17:19
  • Yes. I don't think there is an easy way out of this though. If you build your own token filter, separate from the default `stop` one, how would your filter know that the `stop` filter removed anything? The filters are standalone and separate. Maybe, at indexing time, you don't index `it` but something else (like `_it_`) for those documents where you know that specific stopword shouldn't be removed. – Andrei Stefan Apr 21 '17 at 04:52
  • Thanks. My idea now is to work with 2 indices - one with and one without stopwort filter. At question time I'll deal with their results. – M. Woelfel Apr 21 '17 at 11:23
  • Why don't you use two fields in the same index: one with `stop` filter and one without? – Andrei Stefan Apr 21 '17 at 11:43
  • Ups, yes, that's what I meant. – M. Woelfel Apr 21 '17 at 12:16