lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Muir <rcm...@gmail.com>
Subject Re: DisjunctionMaxQuery and scoring
Date Fri, 20 Apr 2012 06:27:09 GMT
On Thu, Apr 19, 2012 at 8:32 PM, David Murgatroyd <dmurga@gmail.com> wrote:
> In contrast, I think the desire
> is that one and only one of the terms in the document match those in the
> BooleanQuery so that "Rich" would score higher than "Dick Rich", given
> document length normalization. It's almost like a desire for
> BooleanQuery bq = new BooleanQuery(false);
>  bq.set*Maximum*NumberShouldMatch(1);
>

you can, by returning a customized weight with a coord impl that
PUNISHES documents that match > 1 sub.

Take a look at http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java
for some inspiration, especially this part:

BooleanQuery result = new BooleanQuery() {
        @Override
        public Weight createWeight(IndexSearcher searcher) throws IOException {
          return new BooleanWeight(searcher, false) {

            @Override
            public float coord(int overlap, int max) {
              // your logic here when overlap == 1, > 1, etc

-- 
lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message