lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Lucene PhraseQuery Problem No Hits
Date Sat, 11 Feb 2006 18:27:28 GMT

: PhraseQuery pq_query = new PhraseQuery();
: pq_query.add( new Term( "body", "\"circus parade\"" ) );
: <BooleanQuery>.add( pq_query, true, false);

the terms you add to a phrase query need to be exactly equal to the
individual terms that your analyzer would have generated when indexingthe
documents you now want to match.  in your case, it looks like you are
using StandardAnalyzer -- which never generates a term with a space in it.

try this....

    PhraseQuery pq_query = new PhraseQuery();
    pq_query.add(new Term("body", "circus"));
    pq_query.add(new Term("body", "parade"));

:      bq_query.add((PhraseQuery)QueryParser.parse( "\"circus parade\"", "body", new  StandardAnalyzer()
), true, false) ; the top of my head, that seems like it should work.  have you
looked at the toString on the resulting query object to see what it's
structure is?  Compare it with the toString of a query built hte way i
describe above and see if anything is different.


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

View raw message