How to filter the documents based on metadata in opensearch #15233
Replies: 4 comments
-
🤖 Hi @prasannasaikommineni! 😊 I'm Dosu, a friendly bot here to assist you with bugs, queries, or contributing to the repo. Don't worry, a human maintainer will be with you soon, but in the meantime, I'm here to help! Based on the context provided, it seems like you're trying to filter documents based on the However, the way you're trying to use the Instead, you could try using a docsearch.similarity_search(query, k=10 ,search_type="script_scoring",
pre_filter={"term": {"metadata.id": 3}}) Please note that the field name ( Also, please ensure that the If you're still facing issues, could you please provide more details about the structure of your documents and the exact error message you're getting? This would help in identifying the issue more accurately. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
How can I filter a metadata field with text values .I want to prefilter the data bsed on country field |
Beta Was this translation helpful? Give feedback.
-
@dosu-bot Hi, how can I filter metadata in opensearch javascript, for example, I want to filter metadata.source with multiple file names? |
Beta Was this translation helpful? Give feedback.
-
@npthao1312 use boolean_filter to query you data
vector.similarity_search(question, k=k, index_name=index_name,
vector_field="embedding",
text_field="content",
verbose=True,
boolean_filter={"bool": {"should": [
{"match": {"tenant_id": tenant_id}},
]}}
) |
Beta Was this translation helpful? Give feedback.
-
I am trying to filter based on id in metadata I tried in below ways but I am not getting the filtered data
docsearch = OpenSearchVectorSearch.from_documents(
docs, CustomEmbeddings,
http_auth=awsauth,
index_name="index_name",
timeout=300,
opensearch_url="opensearch_url",
connection_class=RequestsHttpConnection,
engine="faiss"
)
docsearch.similarity_search(query, k=10 ,search_type="script_scoring",
pre_filter={"match": {"id": 3}})
and also tried as below
docsearch.similarity_search(query, k=10 ,search_type="script_scoring",
pre_filter={"match": {"metadata.id": 3}})
can someone please help me with the format for filter object
Beta Was this translation helpful? Give feedback.
All reactions