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

Khurram Shehzad <[email protected]> Fri, 24 Aug 2018 10:45:31 +0000
Newsgroups gmane.comp.jakarta.lucene.user,gmane.text.xml.general,gmane.comp.apache.sling.devel
Message-ID <DB5PR02MB14328296E4997CC6DCC66A39DE360@DB5PR02MB1432.eurprd02.prod.outlook.com>
--_000_DB5PR02MB14328296E4997CC6DCC66A39DE360DB5PR02MB1432eurp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,


I have a requirement to replicate following SQL query logic containing OR c=
ondition as

where

((term1=3Da and term2=3Db) OR (term3=3Da and term4=3Db)) 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.Shou=
ld.


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://lu=
cene.apache.org/core/7_3_1/core/org/apache/lucene/search/Collector.html.


Any idea please.


Regards,
Khurram

--_000_DB5PR02MB14328296E4997CC6DCC66A39DE360DB5PR02MB1432eurp_--