lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Susrutha Gongalla <susrutha.gonga...@gmail.com>
Subject Re: Controlling size of matched results in Lucene
Date Thu, 14 May 2015 12:16:42 GMT
Thanks Schindler.
The approach did work for me!
I need the size of results to be same as the indexed documents for further
processing.
The work around you suggested works for this purpose :)

Best,
Susrutha


On Wed, May 13, 2015 at 12:34 PM, Uwe Schindler <uwe@thetaphi.de> wrote:

> There is one possibility to get *all* documents, if you are happy with the
> fact that non-matching documents get a score factor of 0.0:
>
> Scores of SHOULD clauses in a Boolean query get "added". You can combine
> your original query ("yourOriginalQuery"; with real scores) with another
> query ("fakeQuery") matching all documents and having score = 0.0 in a
> single final BooleanQuery ("finalQuery"=, you get score 0.0 for
> non-matching documents, and score 0.0 + realScore => realScore for all
> others:
>
> BooleanQuery finalQuery = new BooleanQuery(true); // BooleanQuery without
> coord factors, so it just adds scores nothing else
> finalQuery.add(yourOriginalQuery, BooleanClause.Occur.SHOULD);
>
> Query fakeQuery = new MatchAllDocsQuery();
> fakeQuery.setBoost(0); // tune the boost, so this query always returns a
> score of 0
> finalQuery.add(fakeQuery, BooleanClause.Occur.SHOULD);
>
> // execute finalQuery!
>
> Hope that helps!
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: Susrutha Gongalla [mailto:susrutha.gongalla@gmail.com]
> > Sent: Tuesday, May 12, 2015 12:28 PM
> > To: general@lucene.apache.org
> > Subject: Controlling size of matched results in Lucene
> >
> > Hello,
> >
> > I am developing a matching algorithm using Lucene 4.10.0 My index
> consists
> > of about 2000 documents.
> > When I use the 'search' method on a query term, I get about n results
> that
> > point to the n documents in index along with their corresponding scores.
> > What I would like to get is - All the 2000 documents with their lucene
> scores
> > along with whether they are matched/unmatched.
> > I would like to control the size of results that lucene returns when I
> search for
> > a query term.
> >
> > I have tried altering the default similarity used in lucene by
> overriding the
> > score methods.
> > However, this did not affect the size of results generated by lucene.
> >
> > I also tried explicitly given 'null' value for filter, when calling the
> 'search'
> > method.
> > This also did not affect the size of results.
> >
> > I just started working with Lucene.
> > Would appreciate any help in this regard!
> >
> > Best,
> > Susrutha Gongalla
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message