i want to filter the suggestions of cognitive search depending on the permissions. all items in the index have like this object
"permissions": {
"readitem": ";[email protected];;[email protected];;[email protected];",
"readlist": ";[email protected];;[email protected];;[email protected];"
},
If the email of the user is one of the emails in the readitem, then he is allowed to see only the suggestions of the items that have his email.
i'm trying to use search.ismatch("[email protected]|[email protected]|[email protected]",permissions/readitem) like that
SuggestOptions sp = new SuggestOptions()
{
UseFuzzyMatching = query.Fuzzy,
Size = 10,
Filter = "search.ismatch(\"[email protected]|[email protected]|[email protected]\",permissions/readitem)",
};
but search.ismatch is only supported in the Search API and I have tried to use odata-filter-expr but it works only with arrays.
Any way to overcome this?
I solved this issue by creating an output field like this.
and I used the rest of the API of cognitive search to select the retrieved items. Everything is described in the Microsoft document. https://learn.microsoft.com/en-us/rest/api/searchservice/autocomplete
here is the Request:
The response is handled like that.