lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: setSimilarity on Query
Date Mon, 12 Nov 2007 15:21:04 GMT

:      The problem is that I want to use QueryParser to construct the
: query for me. I am having to overriding the logic in QueryParser to
: construct my own derived class, which seems to me like a convoluted
: way to just setting the Similariy.

that's the basic design of the QueryParser class - you override to get 
custom behavior.

independent of the QueryParser aspects of your question, adding a 
setSimilarity method to the Query class would be a complete 180 of how it 
currently works right now.

Query classes have to have a getSimilarity method so that their 
Weight/Scorer have a way to access the similarity functions ... but every 
core type of query gets that similarity from the searcher being used when 
hte query is executed.

if the Query class defined a "setSimilarity" then the similarity used by 
one query in a BooleanQuery might not be the same as another query in the 
same query structure ... queryNorms, idfs, tfs ... could all be completley 

A more logical extension point is probably long the lines of past 
discussion towards making all of the Similarity methods take in a field 
name (so you could have a "PerFieldSimilarityWrapper" type implementation) 
and/or changing Searchable.getSimilarity to take in a fieldname param.

i don't think anyone every submitted a patch for either of those ideas 
though ... if you check the mailing list archives you'll see there were 
performance concerns about one of them (i think it was the first one 
because some of those methods are in tight loops, which is unfortunate 
because it's the one that can be done in a backwards compatible way)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message