I need to use elastic search in nestjs to query to retrieve some result from index.
Requirements: I need all results including access_level: "Restricted" and access_level: "Unrestricted" result, but the data with access_level: "Restricted" will excludes: ['image_path'] field in the search result.
However the "Unrestricted" result will remain the same in the result list including 'image_path' field how to do elastic search to do it nestjs do with 1 query
body = {
from: 0,
size: 0,
_source: {
excludes: ["image_path"] // when access_level: Restricted
},
query: {
bool: {
must:[
{
match: {
access_level: "Restricted"
},
match: {
access_level: "Unrestricted"
}
}
],
should: []
},
},
};