I have two indices:
- The
docs
index containing documents and
- The
permissions
index, in which each document is a (doc_id, user_id)
pair specifying that the user user_id
has access to the document doc_id
stored in the docs index.
Here are the definitions of the document classes for the two indices:
class MyDoc(Document):
id = Text()
date = Text()
title = Text()
def save(self, ** kwargs):
return super(MyDoc, self).save(** kwargs)
class Permission(Document):
doc_id = Text()
user_id = Text()
def save(self, ** kwargs):
return super(Permission, self).save(** kwargs)
I am struggling with creating a query searching for a document to which a particular user has access. Here is what I have:
def search_user_doc(
client, docs_index_name, permissions_index_name, user_id, title):
response = client.search(
index=docs_index_name,
body={
"query": {
"bool": {
"must": [
{
"match": {
"title": title
}
},
{
"join": {
"indices": permissions_index_name,
"on": ["doc_id", "id"],
"request": {
"term": {
"user_id": user_id
}
}
}
}
]
}
}
}
)
print(response)
I get the error:
opensearchpy.exceptions.RequestError: RequestError(400, 'x_content_parse_exception', 'unknown query [join]')
.
I understand that this message is saying that there is no join query in OpenSearch
. How can I fix this query?
P.S. The question is now posted in StackOverflow as well.