Quantcast

Multiple field search problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multiple field search problem

Victor Abeytua
Hello everyone,
    In the project I'm currently involved we are using lucene (+
Digester) to index a small number of XML files. To be able to perform
the searches I want, I should need to query the index with something
similar to (where fieldN are XML tags):
(field1:"Policy and planning" OR  field1:Newspapers) AND field2:Spanish

    I haven't been able to find any class that suits my needs and if I
try to use QueryParse.parse() to be able to write the query in "human"
form, the analyzer takes the "and" away and changes the string to lower
case. This is something I can't afford as I need to be able to search by
the exact keywords.
    Any ideas are welcome. Perhaps the answer is right in front of me
but I haven't been able to figure it out.

    Thanks in advance,
    Victor Abeytua
   

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple field search problem

Gusenbauer Stefan
Victor Abeytua wrote:

> Hello everyone,
>    In the project I'm currently involved we are using lucene (+
> Digester) to index a small number of XML files. To be able to perform
> the searches I want, I should need to query the index with something
> similar to (where fieldN are XML tags):
> (field1:"Policy and planning" OR  field1:Newspapers) AND field2:Spanish
>
>    I haven't been able to find any class that suits my needs and if I
> try to use QueryParse.parse() to be able to write the query in "human"
> form, the analyzer takes the "and" away and changes the string to
> lower case. This is something I can't afford as I need to be able to
> search by the exact keywords.
>    Any ideas are welcome. Perhaps the answer is right in front of me
> but I haven't been able to figure it out.
>
>    Thanks in advance,
>    Victor Abeytua
>  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
The lowercasing depends on the analyzer you use perharps you've only put
them into apostrophs like this " if you instanciate the Queryparser you
can specifiy which Boolean operand should be used if no operand is
given. With query.toString() you get the query in an human readable
format for with + for and and so on.
stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple field search problem

Victor Abeytua
Thanks for the quick reply.
    As I supposed, the answer was right in front of me. To build a query
as the one I wanted I have to use the BooleanQuery class:

        Term term1 = new Term("field1", "Policy planning");
        Term term2 = new Term("field1", "Newspapers");
        Term term3 = new Term("field2", "Spanish");
        Query query = new TermQuery(term1);
        Query query2 = new TermQuery(term2);
        Query query3 = new TermQuery(term3);
        BooleanQuery bquery = new BooleanQuery ();
        BooleanQuery bquery2 = new BooleanQuery ();
        bquery.add(query, false, false);
        bquery.add(query2, false, false);
        bquery2.add (bquery, true, false);
        bquery2.add (query3, true, false);
       
        Victor

Gusenbauer Stefan wrote:

>Victor Abeytua wrote:
>
>  
>
>>Hello everyone,
>>   In the project I'm currently involved we are using lucene (+
>>Digester) to index a small number of XML files. To be able to perform
>>the searches I want, I should need to query the index with something
>>similar to (where fieldN are XML tags):
>>(field1:"Policy and planning" OR  field1:Newspapers) AND field2:Spanish
>>
>>   I haven't been able to find any class that suits my needs and if I
>>try to use QueryParse.parse() to be able to write the query in "human"
>>form, the analyzer takes the "and" away and changes the string to
>>lower case. This is something I can't afford as I need to be able to
>>search by the exact keywords.
>>   Any ideas are welcome. Perhaps the answer is right in front of me
>>but I haven't been able to figure it out.
>>
>>   Thanks in advance,
>>   Victor Abeytua
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>>
>>    
>>
>The lowercasing depends on the analyzer you use perharps you've only put
>them into apostrophs like this " if you instanciate the Queryparser you
>can specifiy which Boolean operand should be used if no operand is
>given. With query.toString() you get the query in an human readable
>format for with + for and and so on.
>stefan
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...