lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <>
Subject Re: Analyse TermQuery and PhraseQuery
Date Thu, 19 Feb 2009 12:07:46 GMT

On Feb 19, 2009, at 5:54 AM, Nada Mimouni wrote:

> Hello,
> String ws = " ";
> String query = "The"+ws+"president"+ws+"of"+ws+"the"+ws+"USA"+ws 
> +"is"+ws+""\Barak Obama\"";
> Query q = QueryParser.parse(query, new StandardAnalyser());
> Query q = QueryParser.parse(query, new WhitespaceAnalyser());
> In this example:
> - could we create a query in such a format (combine terms and  
> phrases)?

Sure, why not try it?  Is it not working?

> - what will be the result of the analysis?

Instead of telling you the answer, I'm going to suggest you add:

System.out.println("Query: " + q);

after each of the parses and take a look at what gets printed.  That  
should tell you what you need to know.

> - what should I do to get this hits {president, USA, Barak Obama}?

You should have documents that contain the two words, plus the phrase.

I guess the question back is, do you know you have those documents and  
are not getting results?

Or, are you asking how to submit and run the query?  If that is the  
case, have a look at


Grant Ingersoll

Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids)  
using Solr/Lucene:

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

View raw message