From a26c786bc5fc3d094d7542212b6a517e0999357a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Quintino?= Date: Mon, 16 Dec 2024 16:16:34 +0000 Subject: [PATCH] community: refactor opensearch query constructor to use wildcard instead of match in the contain comparator (#26653) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - **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 Co-authored-by: Eugene Yurtsev Co-authored-by: Chester Curme --- .../langchain_community/query_constructors/opensearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/query_constructors/opensearch.py b/libs/community/langchain_community/query_constructors/opensearch.py index e01ec66639e..8b5f23a80c1 100644 --- a/libs/community/langchain_community/query_constructors/opensearch.py +++ b/libs/community/langchain_community/query_constructors/opensearch.py @@ -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",