I have an index that contains three string fields "user_id", "headline" and "note". I want to search for documents that A) belong to a specific user and B) have a text match in either the "headline" or "notes". I am using AWS Elasticsearch 7.4 and I haven't done any schema or mapping - I simply started to post documents against the index.
What I tried was this:
query = {
"bool": {
"should": [
{"match": {"headline": search_text}},
{"match": {"note": search_text}}
],
"must": {"match": {"user_id": user_id}}
}
}
This works but it finds documents where search text does not match either "headline" or "note". Basically I need a boolean query saying: user_id = :user_id AND (headline = :search_text OR note = :search_text)