diff --git a/app/models/opensearch.rb b/app/models/opensearch.rb index 223e33d6..47a3a4e8 100644 --- a/app/models/opensearch.rb +++ b/app/models/opensearch.rb @@ -20,7 +20,8 @@ def build_query(from) from:, size: SIZE, query:, - aggregations: + aggregations:, + sort: } query_hash[:highlight] = highlight if @highlight @@ -39,6 +40,20 @@ def query } end + def sort + [ + { _score: { order: 'desc' } }, + { + 'dates.value.as_date': { + order: 'desc', + nested: { + path: 'dates' + } + } + } + ] + end + def highlight { pre_tags: [