I have two indices; authors and articles.
Since one author writes several articles, there are 1-to-many relationship between them.
The article index has title, vote, and authorId attributes.
Here is an example index.
PUT /test_authors/
{
"mappings": {
"properties": {
"name": {"type": "keyword"},
}
}
}
PUT /test_articles/
{
"mappings":{
"properties": {
"title": {"type": "keyword"},
"vote": {"type": "long"},
"authorId": {"type": "long"},
}
}
}
sample documents
// sample authors
POST /test_authors/_bulk
{"index":{}}
{"name": "Mick"}
{"index":{}}
{"name": "Tim"}
// sample articles
POST /test_articles/_bulk
{"index":{}}
{"title": "About car", "vote": 5, "authorId": 1}
{"index":{}}
{"title": "About sport", "vote": 2, "authorId": 1}
{"index":{}}
{"title": "About computer", "vote": 1, "authorId": 2}
What I want to do is to search authors, one of whose articles has more than 3 votes.
In the above example, expected result should be only Mick(authorId=1).
In the world of rds, I can do it easily through by single query.
SELECT authors.name FROM authors
LEFT JOIN articles
ON articles.authorId = authors.id
WHERE articles.vote >=3
Can I realize like this kind of thing in elasticsearch?
If not, how can I do this?
Thank you in advance.