Reputation: 12834
Is it possible to configure a Solr field to have multiple/split Filter chains? For example, could I create a Filter chain that looks like this?:
StandardTokenizer
↓
LowerCaseFilter
↙ ↘
SynonymnFilter PhoneticFilter
↓
NGramFilter
I've done quite a bit of searching and haven't found any examples of setting up a Filter chain this way.
EDIT
The main reason I would like to do this in the context of a single field (as opposed to indexing the data twice using a copy field) is for highlighting. If I use a copy field to run a different filter chain on the same data, my highlighting results come back like this:
"highlighting":{
"1234": {
"firstName_phonetic":["<hl>John</hl>"],
"firstName_ngram":["<hl>John</hl>"]
}
}
This makes consuming the results a bit more difficult as the consuming app needs to choose which highlighted field to display. Ideally, I'd get something back like this:
"highlighting":{
"1234": {
"firstName":["<hl>John</hl>"]
}
}
Upvotes: 0
Views: 212
Reputation: 81
The output of one filter goes to the next filter in the chain. There is no support for "branching".
You'll be implementing this method if you want a custom filter.
org.apache.lucene.analysis.TokenStream.incrementToken()
This method returns a boolean. You can see an example here.
Another possible solution is to use a copyField to combine firstName_phonetic and firstName_ngram into firstName and use hl.fl=firstName
Upvotes: 1
Reputation: 15789
It sounds reasonable just to use copyField and index two different fields, each with its own chain.
But, I guess nothing prevents you from implementing your own MyCustomFilter that does what you need, and you plug that one into your conf.
Upvotes: 1