If you start a query with '{' then the entire expression uses that qparser. That's why the second one doesn't work - it ignores the AND... stuff.
Starting a nested query with a lucene qparser character gets it out of that rut. Erik > On Nov 25, 2016, at 14:23, Sandeep Khanzode > <sandeep_khanz...@yahoo.com.INVALID> wrote: > > WORKS: > +{!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO > 2016-11-22T13:59:00Z]'} +(*:* -{!field f=dateRange2 op=Contains > v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) > > > +ConstantScore(IntersectsPrefixTreeFilter(fieldName=dateRange1,queryShape=[2016-11-22T12:01 > TO 2016-11-22T13:59:00],detailLevel=9,prefixGridScanLevel=7)) > +(MatchAllDocsQuery(*:*) > -ConstantScore(ContainsPrefixTreeFilter(fieldName=dateRange2,queryShape=[2016-11-22T12:01 > TO 2016-11-22T13:59:00],detailLevel=9,multiOverlappingIndexedShapes=true))) > > > > > DOES NOT WORK : > {!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO > 2016-11-22T13:59:00Z]'} AND (*:* -{!field f=dateRange2 op=Contains > v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) > > > ConstantScore(IntersectsPrefixTreeFilter(fieldName=dateRange1,queryShape=[2016-11-22T12:01 > TO 2016-11-22T13:59:00],detailLevel=9,prefixGridScanLevel=7)) > SRK > > > On Thursday, November 24, 2016 9:02 PM, Alessandro Benedetti > <benedetti.ale...@gmail.com> wrote: > > > Hey Sandeep, > can you debug the query ( debugQuery=on) and show how the query is parsed ? > > Cheers > > > > On Thu, Nov 24, 2016 at 12:38 PM, Sandeep Khanzode < > sandeep_khanz...@yahoo.com.invalid> wrote: > >> Hi Erick, >> The example record contains ...dateRange1 = [2016-11-22T18:00:00Z TO >> 2016-11-22T20:00:00Z], [2016-11-22T06:00:00Z TO >> 2016-11-22T14:00:00Z]dateRange2 >> = [2016-11-22T12:00:00Z TO 2016-11-22T14:00:00Z]" >> The first query works ... which means that it is able to EXCLUDE this >> record from the result (since the negative dateRange2 clause should return >> false). Whereas the second query should also work but it does not and >> actually pulls the record in the result. >> WORKS: >> +{!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO >> 2016-11-22T13:59:00Z]'} +(*:* -{!field f=dateRange2 op=Contains >> v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) >> >> >> DOES NOT WORK : >> {!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO >> 2016-11-22T13:59:00Z]'} AND (*:* -{!field f=dateRange2 op=Contains >> v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) >> SRK >> >> On Tuesday, November 22, 2016 9:41 PM, Erick Erickson < >> erickerick...@gmail.com> wrote: >> >> >> _How_ does it "not work"? You haven't told us what you expect .vs. >> what you get back. >> >> Plus a sample doc that that violates your expectations (just the >> dateRange field) would >> also help. >> >> Best, >> Erick >> >> On Tue, Nov 22, 2016 at 4:23 AM, Sandeep Khanzode >> <sandeep_khanz...@yahoo.com.invalid> wrote: >>> Hi, >>> I have a simple query that should intersect with dateRange1 and NOT be >> contained within dateRange2. I have tried the following options: >>> >>> WORKS: >>> +{!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO >> 2016-11-22T13:59:00Z]'} +(*:* -{!field f=dateRange2 op=Contains >> v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) >>> >>> >>> DOES NOT WORK : >>> {!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO >> 2016-11-22T13:59:00Z]'} AND (*:* -{!field f=dateRange2 op=Contains >> v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'}) >>> >>> Why? >>> >>> WILL NOT WORK (because of the negative clause at the top level?): >>> {!field f=dateRange1 op=Intersects v='[2016-11-22T12:01:00Z TO >> 2016-11-22T13:59:00Z]'} AND -{!field f=dateRange2 op=Contains >> v='[2016-11-22T12:01:00Z TO 2016-11-22T13:59:00Z]'} >>> >>> >>> SRK >> >> >> >> > > > > -- > -------------------------- > > Benedetti Alessandro > Visiting card - http://about.me/alessandro_benedetti > Blog - http://alexbenedetti.blogspot.co.uk > > "Tyger, tyger burning bright > In the forests of the night, > What immortal hand or eye > Could frame thy fearful symmetry?" > > William Blake - Songs of Experience -1794 England > >