You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Mikhail Khludnev <mk...@griddynamics.com> on 2013/07/22 10:17:23 UTC

Re: short-circuit OR operator in lucene/solr

Short answer, no - it has zero sense.

But after some thinking, it can make some sense, potentially.
DisjunctionSumScorer holds child scorers semi-ordered in a binary heap.
Hypothetically inequality can be enforced at that heap, but heap might not
work anymore for such alignment. Hence, instead of heap TreeSet can be used
for experiment.
fwiw, it's a dev list question.


On Mon, Jul 22, 2013 at 4:48 AM, Deepak Konidena <de...@gmail.com>wrote:

> I understand that lucene's AND (&&), OR (||) and NOT (!) operators are
> shorthands for REQUIRED, OPTIONAL and EXCLUDE respectively, which is why
> one can't treat them as boolean operators (adhering to boolean algebra).
>
> I have been trying to construct a simple OR expression, as follows
>
> q = +(field1:value1 OR field2:value2)
>
> with a match on either field1 or field2. But since the OR is merely an
> optional, documents where both field1:value1 and field2:value2 are matched,
> the query returns a score resulting in a match on both the clauses.
>
> How do I enforce short-circuiting in this context? In other words, how to
> implement short-circuiting as in boolean algebra where an expression A || B
> || C returns true if A is true without even looking into whether B or C
> could be true.
> -Deepak
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
 <mk...@griddynamics.com>

Re: short-circuit OR operator in lucene/solr

Posted by Erick Erickson <er...@gmail.com>.
When calculating a score, you _do_ care about the
rest of the OR clauses since they can contribute to
the score.

It seems that  you'd need an syntax to express
"And I don't care about scoring". Which is really
an fq clause, so maybe this would have to go into
logic there?


On Mon, Jul 22, 2013 at 4:17 AM, Mikhail Khludnev
<mk...@griddynamics.com> wrote:
> Short answer, no - it has zero sense.
>
> But after some thinking, it can make some sense, potentially.
> DisjunctionSumScorer holds child scorers semi-ordered in a binary heap.
> Hypothetically inequality can be enforced at that heap, but heap might not
> work anymore for such alignment. Hence, instead of heap TreeSet can be used
> for experiment.
> fwiw, it's a dev list question.
>
>
> On Mon, Jul 22, 2013 at 4:48 AM, Deepak Konidena <de...@gmail.com>
> wrote:
>>
>> I understand that lucene's AND (&&), OR (||) and NOT (!) operators are
>> shorthands for REQUIRED, OPTIONAL and EXCLUDE respectively, which is why
>> one can't treat them as boolean operators (adhering to boolean algebra).
>>
>> I have been trying to construct a simple OR expression, as follows
>>
>> q = +(field1:value1 OR field2:value2)
>>
>> with a match on either field1 or field2. But since the OR is merely an
>> optional, documents where both field1:value1 and field2:value2 are
>> matched,
>> the query returns a score resulting in a match on both the clauses.
>>
>> How do I enforce short-circuiting in this context? In other words, how to
>> implement short-circuiting as in boolean algebra where an expression A ||
>> B
>> || C returns true if A is true without even looking into whether B or C
>> could be true.
>> -Deepak
>
>
>
>
> --
> Sincerely yours
> Mikhail Khludnev
> Principal Engineer,
> Grid Dynamics
>
>

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