I have documents that look like this (here are two examples):
{ "id": 1234, "title": "the title", "body": "the body", "examples": [ { "evidence_source": "friend", "source_score": 15 }, { "evidence_source": "parent", "source_score": 12 } ] }
and
{ "id": 6346, "title": "new title", "body": "lots of content", "examples": [ { "evidence_source": "friend", "source_score": 10 }, { "evidence_source": "parent", "source_score": 27 }, { "evidence_source": "child", "source_score": 4 } ] }
The format of the subdocuments in the examples
array will always have evidence_source
and source_score
, but there will be a variable sum of these subdocuments, each of which has different evidence_source
values.
I am wondering if it is possible to sort documents in this format based on one of the source_score
values โโcorresponding to the concrete evidence_source
value. I would really like to do this:
- Sort documents by
source_score
in descending order, where the associated evidence_source
is friend
. The resulting order of the id
document will be 1234.6346. - Sort documents by
source_score
in descending order, where the associated evidence_source
is parent
. The resulting order of the id
document will be 6346.1234.
The immediate results that I came up with to create something like 1 and 2 , but I do not believe that they understand exactly what I want to do.
Any ideas on how I can do this? I reflected on some ideas based on indexing these examples
subfiles separately, but I'm pretty new to elasticsearch and therefore looking for some tips on how to achieve my goal in the simplest way (which could be a dream pipe ...)
Update . A message on the elasticsearch mailing list seems to indicate that this is NOT possible, but I wonder if anyone has any other ideas?