community: refactor opensearch query constructor to use wildcard instead of match in the contain comparator (#26653)

- **Description:** Changed the comparator to use a wildcard query
instead of match. This modification allows for partial text matching on
analyzed fields, which improves the flexibility of the search by
performing full-text searches that aren't limited to exact matches.
- **Issue:** The previous implementation used a match query, which
performs exact matches on analyzed fields. This approach limited the
search capabilities by requiring the query terms to align with the
indexed text. The modification to use a wildcard query instead addresses
this limitation. The wildcard query allows for partial text matching,
which means the search can return results even if only a portion of the
term matches the text. This makes the search more flexible and suitable
for use cases where exact matches aren't necessary or expected, enabling
broader full-text searches across analyzed fields.
In short, the problem was that match queries were too restrictive, and
the change to wildcard queries enhances the ability to perform partial
matches.
- **Dependencies:** none
- **Twitter handle:** @Andre_Q_Pereira

---------

Co-authored-by: André Quintino <andre.quintino@tui.com>
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
André Quintino
2024-12-16 16:16:34 +00:00
committed by GitHub
parent 0f9b4bf244
commit a26c786bc5

View File

@@ -36,7 +36,7 @@ class OpenSearchTranslator(Visitor):
Comparator.LTE: "lte",
Comparator.GT: "gt",
Comparator.GTE: "gte",
Comparator.CONTAIN: "match",
Comparator.CONTAIN: "wildcard",
Comparator.LIKE: "fuzzy",
Operator.AND: "must",
Operator.OR: "should",