If my index is comprised of documents with a "date" field, how can I find all the closest neighbors considering there may be multiple origins?
For example, we're interested in finding movies that were released around any movie the given "director" has directed.
The index:
{
"mappings": {
"properties": {
"director": {"type": "keyword"},
"release_date": {"type": "date"}
}
}
}
This would be the query to find all movies directed by Tarantino:
{
"query": {
"bool": {
"filter": {"term": {"director": "Tarantino"}}
}
}
}
Then the query for finding neighbors of the results of the first query. I don't know what I should put in the "origin" in order to reference the other query.
{
"query": {
"bool": {
"should": {
"distance_feature": {
"field": "release_date",
"pivot": "30d",
"origin": "how do I reference the release_dates of the first query?"
}
}
}
}
}
Is using a scripted query the right way to do this? The docs about distance-feature don't mention it, or how to use sub-queries.