Repository navigation
Description
Let's assume we have the following synonym expansions defined in the common rules rewriter:
A =>
SYNONYM: B
SYNONYM: X Y
K =>
SYNONYM: G
After applying this expansion to an input query A K, the query would be represented as follows in Querqy's (q.*) query object model:
q.BQ(
q.DMQ(
q.TQ(A),
q.TQ(B),
q.BQ(
q.DMQ(
q.TQ(X)
),
q.DMQ(
q.TQ(Y)
)
)
),
q.DMQ(
q.TQ(K),
q.TQ(G)
)
)
BQ = 'Boolean Query', DMQ = 'DisMax Query', TQ = 'Term Query' - despite their similar names, these
are not Lucene queries
Let's assume that we want to search in fields f1 and f2. Querqy would build the following Lucene (lc.*) query for our case:
lc.BQ(
lc.DMQ(
lc.TQ(f1:A),
lc.TQ(f2:A),
lc.TQ(f1:B),
lc.TQ(f2:B),
lc.BQ(
lc.DMQ(
lc.TQ(f1:X),
lc.TQ(f2:X)
),
lc.DMQ(
lc.TQ(f1:Y),
lc.TQ(f2:Y),
)
)
),
lc.DMQ(
lc.TQ(f1:K),
lc.TQ(f2:K),
lc.TQ(f1:G),
lc.TQ(f2:G)
)
)
We can set the tie parameter and it would be applied for all DMQs. But as soon as we use tie>0 we would favour the documents that match the most synonyms, for example, documents that match A and B and X Y in our case. This is not what we would indent in most cases.
I suggest to insert one lc.DMQ per top-level query clause (of the BQ) and repeat the above clause structure per field as clauses under that DMQ:
lc.BQ(
lc.DMQ( ### new DMQ, uses current tie parameter for aggregation across fields
lc.DMQ( ### 'old' DMQ, but having only f1 clauses. New tie parameter to aggregate across synonyms.
lc.TQ(f1:A),
lc.TQ(f1:B),
lc.BQ(
lc.DMQ(
lc.TQ(f1:X)
),
lc.DMQ(
lc.TQ(f1:Y)
)
)
),
lc.DMQ( ### 'old' DMQ, but having only f2 clauses. New tie parameter to aggregate across synonyms.
lc.TQ(f2:A),
lc.TQ(f2:B),
lc.BQ(
lc.DMQ(
lc.TQ(f2:X)
),
lc.DMQ(
lc.TQ(f2:Y)
)
)
)
),
lc.DMQ(### new DMQ, uses current tie parameter for aggregation across fields
lc.DMQ(### 'old' DMQ, but having only f1 clauses. New tie parameter to aggregate across synonyms.
lc.TQ(f1:K),
lc.TQ(f1:G)
),
lc.DMQ(### 'old' DMQ, but having only f2 clauses. New tie parameter to aggregate across synonyms.
lc.TQ(f2:K),
lc.TQ(f2:G)
)
)
)
Thus the new tie parameter will add an 'expansion tie breaker' to control aggregation across synonyms or other types of expansions, for example including those generated by word compound handling. We will start with a single 'expansion tie breaker' parameter. If required we might be able to implement this per rewriter later (it would require a modification to Querqy's query object model - see #26 - as opposed to changing the Lucene query object building). Users can use the old/current tie parameter to control score aggregation across fields (as opposed to 'across synonyms/expansions'), which is probably how this parameter was intended originally.
The default value of the 'expansion tie breaker' shall be 0.0. Users will be able to re-create the current behaviour by setting the parameter to 1.0.
Activity
Implementing multiMatchTie #281
renekrie commentedon Feb 17, 2022
The above approach has the issue that it changes boolean matching semantics.
means that X AND Y have to match both in f1 or both in f2 while in the original structure X could match in one field and Y in the other.
The following structure fixes the problem:
And that's how it is implemented in f80f822
Adding end-to-end test for Solr #281
Docs, testing, cleanup #281
Minor optimisation for multiMatchTie in boots #281
Apply multi-match at all levels & code beauty #281
Implementing multiMatchTie #281
Adding end-to-end test for Solr #281
Docs, testing, cleanup #281
Minor optimisation for multiMatchTie in boots #281
Apply multi-match at all levels & code beauty #281
renekrie commentedon Feb 22, 2022
Implemented by #303