Re: SQL OR in lucene : where ((term1=a and term2=b) OR (term3=a and term4=b)) and context in (2,3,4,5.....200)

Tomoko Uchida <[email protected]>
Newsgroups gmane.comp.jakarta.lucene.user,gmane.comp.apache.incubator.ranger.devel,gmane.comp.apache.webservices.general
Message-ID <CAHpHujkNV=VojPmkWta4nWowV-bHBz-jpYpJgvM3gtB=HU=0Yg__40766.8329579339$1535117578$gmane$org@mail.gmail.com>
Hi Khurram,

Lucene query parser's OR operator or Occur.Should are work as expected
for me, I suspect you could miss some points.

> roughly in lucene
> (+term1:a +term2:b) (+term3:a and +term4:b) #context:2 4 7 ... 198

It does not look like an ordinary lucene query string to me ('#' is
not an operator of StandardQueryParser or ClassicQueryParser,) which
parser do you use?
If you try to build a query by Java code, I suggest you post your
exact code snippet.

p.s. dev mailing list is not for user questions, you should post such
questions to java-user list only, anyway. ;)

Regards,
Tomoko

2018年8月24日(金) 19:45 Khurram Shehzad <[email protected]>:
>
> Hi,
>
>
> I have a requirement to replicate following SQL query logic containing OR condition as
>
> where
>
> ((term1=a and term2=b) OR (term3=a and term4=b)) and context in (2,3,4,5.....200)
>
>
> roughly in lucene
>
>
> (+term1:a +term2:b) (+term3:a and +term4:b) #context:2 4 7 ... 198
>
>
> It doesn't seem to me getting desired effect of "OR" logic using Occur.Should.
>
>
> Above lucene query will retrieve all documents satisfying context condition and disregarding first two conditions.
>
>
> But it can be workable, if I manage to apply context condition separately.
>
>
> More probably using custom filtering through Collector interface https://lucene.apache.org/core/7_3_1/core/org/apache/lucene/search/Collector.html.
>
>
> Any idea please.
>
>
> Regards,
> Khurram



--
Tomoko Uchida
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.