lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Smith G <gudumba.sm...@gmail.com>
Subject Re: relation among Terms included in Query
Date Mon, 28 Dec 2009 23:18:41 GMT
Hi,
        Thank you very much.. that should help.. meanwhile I run cases
and write again if I get stuck once more in the same context.
Thanks

2009/12/28 AHMET ARSLAN <iorixxx@yahoo.com>:
>> Hello All,
>>             I have observed
>> extractTerms() in the class
>> org.apache.lucene.search.Query which returns set of terms
>> extracted
>> from user input query. Is there any chance of getting the
>> connecting-operator between all those terms. for example..
>> Term1 OR
>> Term2 AND Term3 ..    or  Term1 AND Term2
>> AND Term3 , etc..
>> Thanks.
>
> You can extract org.apache.lucene.search.BooleanClause from BooleanQuery. Something like:
>
>
>  if (contents instanceof BooleanQuery) {
>
> BooleanQuery bq = (BooleanQuery) contents;
> BooleanClause[] bclauses = bq.getClauses();
>
>            for (int i = 0; i < bclauses.length; i++) {
>
>                Query qc = bclauses[i].getQuery();
>
>
>                if (bclauses[i].getOccur().equals(BooleanClause.Occur.MUST_NOT))
{
>                 // NOT
>
>                }
>                else if (bclauses[i].getOccur().equals(BooleanClause.Occur.MUST))
{
>                // AND
>
>                }
>                else if (bclauses[i].getOccur().equals(BooleanClause.Occur.SHOULD))
{
>                // OR
>
>                }
>           }
> }
>
> Hope this helps.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


Mime
View raw message