It doesn't look like this is supported in any way that is at all
straightforward. http://wiki.apache.org/solr/SolrPlugins talks about
the easy ways to parameterize plugins, and they don't include what
you're after.
I think maybe you could extend the query parser you are currently using,
wrap the parse() method, get a hold of your analyzer, which maybe is
your own class with special knowledge of its filter chain and can inform
the filter that it's being used in "query" mode; otherwise it would
default to index mode.
If you are letting Solr generate the Analyzer, or maybe in either case
(?) you could call Analyzer.reusableTokenStream() to get the
TokenStream, but from there things get murky. I don't think TokenStream
provides any mechanism to walk the chain so you could find your special
filter and inform it of its status. You'd probably have to add your own
mechanism for tracking this, extending all TokenStreams, but I don't
think this is actually feasible since these are required to be final!
-Mike
On 6/1/2011 12:23 PM, Mike Schultz wrote:
I should have explained that the queryMode parameter is for our own custom
filter. So the result is that we have 8 filters in our field definition.
All the filter parameters (30 or so) of the query time and index time are
identical EXCEPT for our one custom filter which needs to know if it's in
query time or index time mode. If we could determine inside our custom code
whether we're indexing or querying, then we could omit the query time
definition entirely and save about 50 lines of configuration and be much
less error prone.
One possible solution would be if we could get at the SolrCore from within a
filter. Then at init time we could iterate through the filter chains and
determine when we find a factory == this. (I've done this in other places
where it's useful to know the name of a ValueSourceParser for example)
--
View this message in context:
http://lucene.472066.n3.nabble.com/Index-vs-Query-Time-Aware-Filters-tp3009450p3011556.html
Sent from the Solr - User mailing list archive at Nabble.com.