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 Abu Abdulla alhanbali <mo...@gmail.com> on 2007/08/10 06:20:56 UTC

formalizing a query

Hi,

I need your help in formalizing this query:

(field1:query1 AND field2:query2) OR
(field1:query3 AND field2:query4) OR
(field1:query5 AND field2:query6) OR
(field1:query7 AND field2:query8) ... etc

Please give the code since I'm new to lucene
how we can use MultiFieldQueryParser or any parser to do the job

greatly appreciated

Re: formalizing a query

Posted by Abu Abdulla <mo...@gmail.com>.
Hi,

I have done using this:

final QueryParser filterQueryParser = new QueryParser("", new
KeywordAnalyzer());
												hits = indexSearcher.search(query, new
QueryWrapperFilter(filterQueryParser.parse(filterQuery)));

where filterQuery= "(field1:query1 AND field2:query2) OR (field1:query3 AND
field2:query4)"

If there are other methods that can do it in a professional way. please
comment.

Thanks


Sagar Naik-2 wrote:
> 
> Hey,
> 
> I think u can try :
> 
> MultiFieldQueryParser.parse(String[] queries, String[] fields, 
> BooleanClause.Occur[] flags,
>       Analyzer analyzer)
> 
> The flags arrray will get u ORs and ANDs in places u need
> 
> - Sagar Naik
> 
> Abu Abdulla alhanbali wrote:
>> Thanks for the help,
>>
>> please provide the code to do that.
>>
>> I tried with this one but it didn't work:
>>
>> Query filterQuery = MultiFieldQueryParser.parse(new String{query1,
>> query2,
>> query3, query4, .... }, new String{field1, field2, field1, field2, ... },
>> new KeywordAnalyzer());
>>
>> this results in:
>>
>> field1:query1 OR field2:query2 OR
>> field1:query3 OR field2:query4 ... etc
>>
>> and NOT:
>>
>> (field1:query1 AND field2:query2) OR
>> (field1:query3 AND field2:query4) ... etc
>>
>> please help.
>>
>>
>> On 8/10/07, Erick Erickson <er...@gmail.com> wrote:
>>   
>>> I *strongly* suggest you get a copy of Luke. It'll allow you to form
>>> queries
>>> and see the results and you can then answer this kind of question as
>>> well
>>> as many others.
>>>
>>> Meanwhile, please see
>>> http://lucene.apache.org/java/docs/queryparsersyntax.html
>>>
>>> Erick
>>>
>>> On 8/10/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
>>>     
>>>> Hi,
>>>>
>>>> I need your help in formalizing this query:
>>>>
>>>> (field1:query1 AND field2:query2) OR
>>>> (field1:query3 AND field2:query4) OR
>>>> (field1:query5 AND field2:query6) OR
>>>> (field1:query7 AND field2:query8) ... etc
>>>>
>>>> Please give the code since I'm new to lucene
>>>> how we can use MultiFieldQueryParser or any parser to do the job
>>>>
>>>> greatly appreciated
>>>>
>>>>       
>>
>>   
> 
> 
> -- 
> Always vizz it us @ visvo.com
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content and is believed to be clean.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/formalizing-a-query-tf4246564.html#a12210481
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: formalizing a query

Posted by Sagar Naik <sa...@visvo.com>.
Hey,

I think u can try :

MultiFieldQueryParser.parse(String[] queries, String[] fields, 
BooleanClause.Occur[] flags,
      Analyzer analyzer)

The flags arrray will get u ORs and ANDs in places u need

- Sagar Naik

Abu Abdulla alhanbali wrote:
> Thanks for the help,
>
> please provide the code to do that.
>
> I tried with this one but it didn't work:
>
> Query filterQuery = MultiFieldQueryParser.parse(new String{query1, query2,
> query3, query4, .... }, new String{field1, field2, field1, field2, ... },
> new KeywordAnalyzer());
>
> this results in:
>
> field1:query1 OR field2:query2 OR
> field1:query3 OR field2:query4 ... etc
>
> and NOT:
>
> (field1:query1 AND field2:query2) OR
> (field1:query3 AND field2:query4) ... etc
>
> please help.
>
>
> On 8/10/07, Erick Erickson <er...@gmail.com> wrote:
>   
>> I *strongly* suggest you get a copy of Luke. It'll allow you to form
>> queries
>> and see the results and you can then answer this kind of question as well
>> as many others.
>>
>> Meanwhile, please see
>> http://lucene.apache.org/java/docs/queryparsersyntax.html
>>
>> Erick
>>
>> On 8/10/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
>>     
>>> Hi,
>>>
>>> I need your help in formalizing this query:
>>>
>>> (field1:query1 AND field2:query2) OR
>>> (field1:query3 AND field2:query4) OR
>>> (field1:query5 AND field2:query6) OR
>>> (field1:query7 AND field2:query8) ... etc
>>>
>>> Please give the code since I'm new to lucene
>>> how we can use MultiFieldQueryParser or any parser to do the job
>>>
>>> greatly appreciated
>>>
>>>       
>
>   


-- 
Always vizz it us @ visvo.com


-- 
This message has been scanned for viruses and
dangerous content and is believed to be clean.


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


Re: formalizing a query

Posted by Abu Abdulla alhanbali <mo...@gmail.com>.
Thanks for the help,

please provide the code to do that.

I tried with this one but it didn't work:

Query filterQuery = MultiFieldQueryParser.parse(new String{query1, query2,
query3, query4, .... }, new String{field1, field2, field1, field2, ... },
new KeywordAnalyzer());

this results in:

field1:query1 OR field2:query2 OR
field1:query3 OR field2:query4 ... etc

and NOT:

(field1:query1 AND field2:query2) OR
(field1:query3 AND field2:query4) ... etc

please help.


On 8/10/07, Erick Erickson <er...@gmail.com> wrote:
>
> I *strongly* suggest you get a copy of Luke. It'll allow you to form
> queries
> and see the results and you can then answer this kind of question as well
> as many others.
>
> Meanwhile, please see
> http://lucene.apache.org/java/docs/queryparsersyntax.html
>
> Erick
>
> On 8/10/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
> >
> > Hi,
> >
> > I need your help in formalizing this query:
> >
> > (field1:query1 AND field2:query2) OR
> > (field1:query3 AND field2:query4) OR
> > (field1:query5 AND field2:query6) OR
> > (field1:query7 AND field2:query8) ... etc
> >
> > Please give the code since I'm new to lucene
> > how we can use MultiFieldQueryParser or any parser to do the job
> >
> > greatly appreciated
> >
>

Re: formalizing a query

Posted by Erick Erickson <er...@gmail.com>.
I *strongly* suggest you get a copy of Luke. It'll allow you to form queries
and see the results and you can then answer this kind of question as well
as many others.

Meanwhile, please see
http://lucene.apache.org/java/docs/queryparsersyntax.html

Erick

On 8/10/07, Abu Abdulla alhanbali <mo...@gmail.com> wrote:
>
> Hi,
>
> I need your help in formalizing this query:
>
> (field1:query1 AND field2:query2) OR
> (field1:query3 AND field2:query4) OR
> (field1:query5 AND field2:query6) OR
> (field1:query7 AND field2:query8) ... etc
>
> Please give the code since I'm new to lucene
> how we can use MultiFieldQueryParser or any parser to do the job
>
> greatly appreciated
>