From e9d67cc63e323c398ec59b7a328912f017a0309d Mon Sep 17 00:00:00 2001 From: Brendan Quinn Date: Mon, 22 Apr 2024 18:22:03 +0000 Subject: [PATCH] Updates hybrid search query to match against all_titles using the 'and' operator and the 'english' stopword analyzer. --- chat/src/helpers/response.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chat/src/helpers/response.py b/chat/src/helpers/response.py index 351be8ff..156f9048 100644 --- a/chat/src/helpers/response.py +++ b/chat/src/helpers/response.py @@ -48,7 +48,15 @@ def extract_prompt_value(v): def prepare_response(config): try: - subquery = {"match": {"all_text": {"query": config.question}}} + subquery = { + "match": { + "all_titles": { + "query": config.question, + "operator": "AND", + "analyzer": "english" + } + } + } docs = config.opensearch.similarity_search( query=config.question, k=config.k, subquery=subquery, _source={"excludes": ["embedding"]} )