I have an index containing documents which have the object_type
field set to comment
or post
. For comment
I want to search only the text
field, for post
I want to search both text
and post_title
. Essentially I'd like to query something like this: (doc.object_type = "post" and (doc.text matching text or doc.post_title matching text)) or (doc.object_type = "comment" and doc.text matching text)
When I run the query below I'm seeing post
s come up in the results despite the comment
filter. Can someone explain what the inner filter clause does here? Is it possible to nest a filter
inside a should
?
{
"from": 0,
"size": 5,
"query": {
"bool": {
"filter": {
"bool": {
"should": [
{
"term": {
"channel_name": "jeanne4"
}
}
]
}
},
"should": [
{
"bool": {
"filter": {
"term": {
"object_type": "comment"
}
},
"must": {
"match": {
"text": "amtrak"
}
}
}
}
]
}
}
}