I have an array of articles (i.e. from newspapers) in a MongoDB database that is indexed into Elasticsearch. Each article has any number of authors, like: ['John Doe', 'Jane Doe'].
In Es, I have aggregation by author working properly, but I also want to apply a post_filter to filter results by author. How should a post_filter query be designed to handle this?
Article schema in Es (can be modified if necessary):
{
...
authors: ['Michael Jordan', 'Kobe Bryant'],
authorsString: 'Michael Jordan;Kobe Bryant;'
}
This is an example query before applying the post_filter:
{
...
aggs: {
authors: {
terms: {
field: 'authors.keyword',
},
},
},
post_filter: {},
}
If I want to find articles of which at least one of the authors is "Michael Jordan", how do I use post_filter to do so?