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 de...@web.de on 2006/01/19 16:01:51 UTC

What's the differents between QueryParser and Query

Hi all!
I've a question about the lucene search method. What is the different between a search with the class lucene.queryParser.QueryParser and the class lucene.search.Query and their subclasses?
For example: With the WildcardQuery I can search for * at the beginning of a term, but not with the method QueryParser.parse(). But I get the same search string with Query.toString(). Why?

Some background about my project:
I have to decide if I build a Query with the Query class and their subclasses or if I build it with the static method QueryParser.parse()
The sizes of my indexes are pretty different. They might reach a size of 100,000 docs and more. Unfortunately the index changes frequently.
What is the best way to search in such an index, and why?

Pleased for every kind of help!

Matt
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


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


Re: What's the differents between QueryParser and Query

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jan 19, 2006, at 10:01 AM, der_grosse_hui@web.de wrote:
> I've a question about the lucene search method. What is the  
> different between a search with the class  
> lucene.queryParser.QueryParser and the class lucene.search.Query  
> and their subclasses?

QueryParser is a Query "factory".   It takes a String and parses it  
into a Query, and depending on the expression in that String it could  
be one of many different types of Query subclasses.

There is no difference in searching at all.... you search with a  
Query, and how that query got built is immaterial.

> For example: With the WildcardQuery I can search for * at the  
> beginning of a term, but not with the method QueryParser.parse().  
> But I get the same search string with Query.toString(). Why?

QueryParser has its limitations, and one of them is to prevent the  
possibility of a prefixed wildcard query such as "*foo" which would  
have to enumerate all terms in the index and quite possibly blow up  
BooleanQuery as it rewrites the query or perhaps cause performance  
issues.

QueryParser is a one-size-sorta-fits-all kinda thing.  It's a decent  
general purpose tool to get going, but most of my projects use  
QueryParser sparingly only within small pieces of the ultimate query.

> Some background about my project:
> I have to decide if I build a Query with the Query class and their  
> subclasses or if I build it with the static method QueryParser.parse()
> The sizes of my indexes are pretty different. They might reach a  
> size of 100,000 docs and more. Unfortunately the index changes  
> frequently.
> What is the best way to search in such an index, and why?
>
> Pleased for every kind of help!

Neither QueryParser or Query factor into the size of the index or how  
to manage a frequently changing index, totally unrelated topics.

	Erik


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