From 52c620cce7ee5dfb873a5f0d3c64cc138c782081 Mon Sep 17 00:00:00 2001 From: jzonthemtn Date: Tue, 21 Jan 2025 14:29:32 -0500 Subject: [PATCH] Updates for hybrid query. Signed-off-by: jzonthemtn --- scripts/hybrid_query.txt | 28 +++++++++++++++++++ scripts/opensearch-scripts/create-pipeline.sh | 26 ----------------- scripts/opensearch-scripts/get-pipelines.sh | 3 ++ scripts/run-query-set.json | 9 +++--- 4 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 scripts/hybrid_query.txt delete mode 100755 scripts/opensearch-scripts/create-pipeline.sh create mode 100755 scripts/opensearch-scripts/get-pipelines.sh diff --git a/scripts/hybrid_query.txt b/scripts/hybrid_query.txt new file mode 100644 index 0000000..752c961 --- /dev/null +++ b/scripts/hybrid_query.txt @@ -0,0 +1,28 @@ +{ + "_source": { + "excludes": [ + "title_embedding" + ] + }, + "query": { + "hybrid": { + "queries": [ + { + "match": { + "title_text": { + "query": "#$query##" + } + } + }, + { + "neural": { + "title_embedding": { + "query_text": "#$query##", + "k": 50 + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/scripts/opensearch-scripts/create-pipeline.sh b/scripts/opensearch-scripts/create-pipeline.sh deleted file mode 100755 index 24342d7..0000000 --- a/scripts/opensearch-scripts/create-pipeline.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -e - -curl -X PUT http://localhost:9200/_search/pipeline/hybrid_pipeline -H "Content-type: application/json" -d' -{ - "request_processors": [ - { - "filter_query" : { - "tag" : "tag1", - "description" : "This processor is going to restrict to publicly visible documents", - "query" : { - "term": { - "visibility": "public" - } - } - } - } - ], - "response_processors": [ - { - "rename_field": { - "field": "message", - "target_field": "notification" - } - } - ] -}' diff --git a/scripts/opensearch-scripts/get-pipelines.sh b/scripts/opensearch-scripts/get-pipelines.sh new file mode 100755 index 0000000..876fd9d --- /dev/null +++ b/scripts/opensearch-scripts/get-pipelines.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +curl http://localhost:9200/_search/pipeline | jq \ No newline at end of file diff --git a/scripts/run-query-set.json b/scripts/run-query-set.json index ebccf1a..6db1519 100644 --- a/scripts/run-query-set.json +++ b/scripts/run-query-set.json @@ -1,10 +1,11 @@ { - "query_set_id": "6d2a8d56-a9e6-4f99-9a81-482974d11c32", - "judgments_id": "c2d46e06-0e37-4370-b547-296b554c646e", + "query_set_id": "6b1ac777-758d-4f33-9bb6-7e3f15e77637", + "judgments_id": "76267535-0591-4e13-9e3d-8de5cb1329a6", "index": "ecommerce", - "search_pipeline": "", + "search_pipeline": "hybrid-search-pipeline", "id_field": "asin", "k": 10, "threshold": 1.0, - "query": "{\"query\": {\"match\": {\"description\": \"#$query##\"}}}" + "query": "{\"_source\": {\"excludes\": [\"title_embedding\"]},\"query\": {\"hybrid\": {\"queries\": [{\"match\": {\"title_text\": {\"query\": \"#$query##\"}}},{\"neural\": {\"title_embedding\": {\"query_text\": \"#$query##\",\"k\": 50}}}]}}}", + "not_used_query": "{\"query\": {\"match\": {\"description\": \"#$query##\"}}}" }