[prev in list] [next in list] [prev in thread] [next in thread]
List: lucene-user
Subject: Re: relation among Terms included in Query
From: Smith G <gudumba.smith () gmail ! com>
Date: 2009-12-28 23:18:41
Message-ID: 171c79530912281518g1e5e9074l34169339e806a81c () mail ! gmail ! com
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic