Short-circuit OR operator in Lucene/Solr -
i understand lucene's , (&&), or (||) , not (!) operators shorthands required, optional , exclude respectively, why 1 can't treat them boolean operators (adhering boolean algebra).
i have been trying construct simple or expression, follows
q = +(field1:value1 or field2:value2)
with match on either field1 or field2. since or merely optional, documents both field1:value1 , field2:value2 matched, query returns score resulting in match on both clauses.
how enforce short-circuiting in context? in other words, how implement short-circuiting in boolean algebra expression || b || c returns true if true without looking whether b or c true.
strictly speaking, no, there no short circuiting boolean logic. if document found 1 term, can't tell not check other. lucene inverted index, doesn't check documents matches directly. if search a or b
, finds a
, gets documents have indexed value. gets b
in index, , list of documents containing (this simplifying somewhat, hope gets point across). doesn't make sense not check documents in a
found. further, query provided, matches on document still need enumerated in order acquire correct score.
however, did mention scores! suspect trying @ if 1 query term in set found, not compound score other elements. is, (a or b)
, score either score-a
or score-b
, rather score-a * score-b
or such (sorry if making wrong assumption here, of course).
that disjunctionmaxquery
for. adding each subquery render score equal maximum of scores of subqueries, rather product.
in solr, should learn dismaxqparserplugin , it's more recent incarnation, extendeddismax, which, if i'm close mark here, should serve well.
Comments
Post a Comment