You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Ron Grabowski <ro...@yahoo.com> on 2009/10/31 00:11:51 UTC

Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

I can convert this text into a Query using  just TermQuery and BooleanQuery:

 name:"ACME Produce" AND city:Anytown AND zip:90210

If I create the Query object on my own will I loose all the  benefits from things like  StandardAnalyzer? Is there a way I can submit an object graph to QueryParser so I can get the benefits of its analyzer without making it parse the raw string? My input is coming from well defined areas; its not free form where the user can enter anything they want.

Can I use a StandardAnalyzer myself then take its output and create the appropriate Query objects then join all of them into a BooleanQuery?

I'm using /tags/Lucene.Net_2_4_0.

Re: Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

Posted by Erik Hatcher <er...@gmail.com>.
It's quite common to build a Query by API rather than through  
QueryParser, exactly as you mentioned.  Manually run through an  
Analyzer's output to build whatever type of query clauses desired.

	Erik

On Oct 30, 2009, at 8:55 PM, Ron Grabowski wrote:

> Is there a way to avoid using QueryParser altogether? I don't need  
> all the text parsed, I just want to run the name field through an  
> analyzer and use the output of that along with TermQuerys for the  
> zip and city. I'm wanting to do  ~2,500 specific searches on an  
> index with between 26m documents. I know ahead of time what most of  
> my fields will be. I thought I could save some time by not having to  
> separate  my fields, making a giant string, then having QueryParser  
> split the string back into terms to search.
>
>
>
> ----- Original Message ----
> From: Digy <di...@gmail.com>
> To: lucene-net-user@incubator.apache.org
> Sent: Fri, October 30, 2009 7:45:21 PM
> Subject: RE: Is it generally a good idea to avoid using QueryParser  
> if you know how to make the Query yourself?
>
> You can combine queries . (such as your custom "TermQuery" + the  
> result of a
> "QueryParser.Parse")
>
> DIGY
>
> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com]
> Sent: Saturday, October 31, 2009 1:12 AM
> To: lucene-net-user@incubator.apache.org
> Subject: Is it generally a good idea to avoid using QueryParser if  
> you know
> how to make the Query yourself?
>
> I can convert this text into a Query using  just TermQuery and  
> BooleanQuery:
>
> name:"ACME Produce" AND city:Anytown AND zip:90210
>
> If I create the Query object on my own will I loose all the   
> benefits from
> things like  StandardAnalyzer? Is there a way I can submit an object  
> graph
> to QueryParser so I can get the benefits of its analyzer without  
> making it
> parse the raw string? My input is coming from well defined areas;  
> its not
> free form where the user can enter anything they want.
>
> Can I use a StandardAnalyzer myself then take its output and create  
> the
> appropriate Query objects then join all of them into a BooleanQuery?
>
> I'm using /tags/Lucene.Net_2_4_0.


RE: Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

Posted by Digy <di...@gmail.com>.
I am not sure that I can understand what you exactly want to do but, you can
create an analyzer, get the output and then see what you can do with it.

StandardAnalyzer analyzer = new StandardAnalyzer();
TokenStream stream = analyzer.TokenStream("", new
System.IO.StringReader("your text"));
Token token = stream.Next();
while (  token !=null )
{
	Console.WriteLine(token.TermText());
	token = stream.Next();
}

DIGY

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Saturday, October 31, 2009 2:55 AM
To: lucene-net-user@incubator.apache.org
Subject: Re: Is it generally a good idea to avoid using QueryParser if you
know how to make the Query yourself?

Is there a way to avoid using QueryParser altogether? I don't need all the
text parsed, I just want to run the name field through an analyzer and use
the output of that along with TermQuerys for the zip and city. I'm wanting
to do  ~2,500 specific searches on an index with between 26m documents. I
know ahead of time what most of my fields will be. I thought I could save
some time by not having to separate  my fields, making a giant string, then
having QueryParser split the string back into terms to search.




----- Original Message ----
From: Digy <di...@gmail.com>
To: lucene-net-user@incubator.apache.org
Sent: Fri, October 30, 2009 7:45:21 PM
Subject: RE: Is it generally a good idea to avoid using QueryParser if you
know how to make the Query yourself?

You can combine queries . (such as your custom "TermQuery" + the result of a
"QueryParser.Parse")

DIGY

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Saturday, October 31, 2009 1:12 AM
To: lucene-net-user@incubator.apache.org
Subject: Is it generally a good idea to avoid using QueryParser if you know
how to make the Query yourself?

I can convert this text into a Query using  just TermQuery and BooleanQuery:

name:"ACME Produce" AND city:Anytown AND zip:90210

If I create the Query object on my own will I loose all the  benefits from
things like  StandardAnalyzer? Is there a way I can submit an object graph
to QueryParser so I can get the benefits of its analyzer without making it
parse the raw string? My input is coming from well defined areas; its not
free form where the user can enter anything they want.

Can I use a StandardAnalyzer myself then take its output and create the
appropriate Query objects then join all of them into a BooleanQuery?

I'm using /tags/Lucene.Net_2_4_0.


Re: Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

Posted by Ron Grabowski <ro...@yahoo.com>.
Is there a way to avoid using QueryParser altogether? I don't need all the text parsed, I just want to run the name field through an analyzer and use the output of that along with TermQuerys for the zip and city. I'm wanting to do  ~2,500 specific searches on an index with between 26m documents. I know ahead of time what most of my fields will be. I thought I could save some time by not having to separate  my fields, making a giant string, then having QueryParser split the string back into terms to search.



----- Original Message ----
From: Digy <di...@gmail.com>
To: lucene-net-user@incubator.apache.org
Sent: Fri, October 30, 2009 7:45:21 PM
Subject: RE: Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

You can combine queries . (such as your custom "TermQuery" + the result of a
"QueryParser.Parse")

DIGY

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Saturday, October 31, 2009 1:12 AM
To: lucene-net-user@incubator.apache.org
Subject: Is it generally a good idea to avoid using QueryParser if you know
how to make the Query yourself?

I can convert this text into a Query using  just TermQuery and BooleanQuery:

name:"ACME Produce" AND city:Anytown AND zip:90210

If I create the Query object on my own will I loose all the  benefits from
things like  StandardAnalyzer? Is there a way I can submit an object graph
to QueryParser so I can get the benefits of its analyzer without making it
parse the raw string? My input is coming from well defined areas; its not
free form where the user can enter anything they want.

Can I use a StandardAnalyzer myself then take its output and create the
appropriate Query objects then join all of them into a BooleanQuery?

I'm using /tags/Lucene.Net_2_4_0.

RE: Is it generally a good idea to avoid using QueryParser if you know how to make the Query yourself?

Posted by Digy <di...@gmail.com>.
You can combine queries . (such as your custom "TermQuery" + the result of a
"QueryParser.Parse")

DIGY

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Saturday, October 31, 2009 1:12 AM
To: lucene-net-user@incubator.apache.org
Subject: Is it generally a good idea to avoid using QueryParser if you know
how to make the Query yourself?

I can convert this text into a Query using  just TermQuery and BooleanQuery:

 name:"ACME Produce" AND city:Anytown AND zip:90210

If I create the Query object on my own will I loose all the  benefits from
things like  StandardAnalyzer? Is there a way I can submit an object graph
to QueryParser so I can get the benefits of its analyzer without making it
parse the raw string? My input is coming from well defined areas; its not
free form where the user can enter anything they want.

Can I use a StandardAnalyzer myself then take its output and create the
appropriate Query objects then join all of them into a BooleanQuery?

I'm using /tags/Lucene.Net_2_4_0.