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 Eyal <ey...@gmail.com> on 2005/07/19 14:10:33 UTC

Using QueryParser with a single field

Hi,
 
In my client application I allow the user to build a query by selecting a
field from a combobox and entering a value to search by.
I want the user to enter free text queries for each field, but I don't want
to parse it myself so I thought I'd use QueryParser for that. My problem is
that if the user will (for example) select a field called author and enter
the following text: 'John content:MyContent' 
QueryParser will build a query for author:John OR content:MyContent. I want
QueryParser to ignore other fields.
Any method in QueryParser to allow that? If not - any other suggestions?
 
Thanks,
Eyal 


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


Re: Using QueryParser with a single field

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 19, 2005, at 8:10 AM, Eyal wrote:

> Hi,
>
> In my client application I allow the user to build a query by  
> selecting a
> field from a combobox and entering a value to search by.
> I want the user to enter free text queries for each field, but I  
> don't want
> to parse it myself so I thought I'd use QueryParser for that. My  
> problem is
> that if the user will (for example) select a field called author  
> and enter
> the following text: 'John content:MyContent'
> QueryParser will build a query for author:John OR  
> content:MyContent. I want
> QueryParser to ignore other fields.
> Any method in QueryParser to allow that? If not - any other  
> suggestions?

There is no such switch in QueryParser to disable fielded queries.  A  
custom QueryParser would be needed to make this happen.

If you only need TermQuery and PhraseQuery you could do without  
QueryParser altogether in this situation and process (not quite  
"parse") the text fields by building up the appropriate query.

     Erik


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