Restrict user to fetch only subset of index data while hitting opensearch API's

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue: # Query to get all documents

    query = {"query": {"match_all": {}}}

    \# Execute search query

    response = client.search(index=INDEX_NAME, size=1000, body=query)

we have python script to fetch data from my Local opensearch with help of client

so am using opensearch APi’s to get data

so here how can i restrict some user on with subset of index only

lets say we have customer index, containing 10 documents :slight_smile:

  1. if in index field is Customer type - [Finance & Marketplace]

so we would like create subset of index on hitting of api so market place user could only see market place docuyments only

let me know if any one have solution on this please,

Thanks

Configuration:

Relevant Logs or Screenshots:

@amolusare Thank you for the question. Do I understand correctly that you would like to only receive a subset of documents from a particular index for a given user?

If that is the case you can use Document Level Security.

If you would like the exact query to add to DLS role, please provide sample documents in the particular index and the mapping for the same.