You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sol myr <so...@gmail.com> on 2011/04/06 21:12:03 UTC

PhraseQuery with huge slop?

Hi,

I need to run and "AND" query, with a twist: giving higher ranking for
"exact match".
So when searching for  BIG BEN
- Give high rank for the Document  "BIG BEN is in London"
 - Lower rank for  "It's a BIG day for my dear friend BEN"

Following good advice from this list (thanks!), I used 2 separate
queries (the query "+BIG +BEN"  and the exact-phrase "BIG BEN").
Ending up with:
Query andQ=parser.parse("+big +ben");
Query phraseQ=parser.parse("\"big ben\"");
phraseQ.setBoost(5); // Prioritize exact match
// Combined main query:
BooleanQuery main=new BooleanQuery();
main.add(andQ, SHOULD);
main.add(phraseQ, SHOULD);

This works, but someone suggested an alternative: PhraseQuery with a very
large SLOP (to cover the entire document lenght).
Is this recommended? Does a large SLOP damage performance?
My documents currently have just several *hundreds* of words (but I'm
curious whether it will scale for *thousands* of words).

Thanks :)