I've indexed my documents as follows:
doc = {
"_index": index_name,
"_source": {
"field": "bm25",
"passage": passage,
"passage_id": pid,
"level1": level1,
"level2": level2,
"level3": level3,
"level4": level4
},
"_op_type": "index"
}
With the ES index, I'm trying to retrieve relevant documents using a passage as a query (linking a passage to relevant passages). However, on top of the input query passage being closely matched with the passage field from the indexed documents, I'd like to consider level1~4 fields as well.
Given the query_passage
, query_level1
, query_level2
, query_level3
, and query_level4
, I want to retrieve documents that share similar passages but also share the same level1~4.
I've wrote phrase_query as below, but it's giving me opensearchpy.exceptions.RequestError: RequestError(400, 'parsing_exception', 'unknown query [query]')
error message.
phrase_query = {
"query": {
"bool": {
"should": [
{"multi_match":
{"query": query_passage,
"fields": ["passage"]
}
}
],
"must": [
{
"match": {
"level1": {
"query": query_level1
}
}
},
{
"match": {
"level2": {
"query": query_level2
}
}
},
{
"match": {
"level3": {
"query": query_level3
}
}
},
{
"match": {
"level4": {
"query": query_level4
}
}
}
]
}
}
}
I want query levels to exactly match levels and auery_passage to be the ingredient where BM25 score is calculated w.r.t the passage
field. Any help would be appreciated!