Skip to content

Commit

Permalink
Merge pull request #790 from MITLibraries/gdt-185-sort_by_score_then_…
Browse files Browse the repository at this point in the history
…date

Introduces secondary sort by date
  • Loading branch information
JPrevost committed Feb 13, 2024
2 parents 2d200fd + e1cdcbd commit 3c9db10
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/models/opensearch.rb
Expand Up @@ -20,7 +20,8 @@ def build_query(from)
from:,
size: SIZE,
query:,
aggregations:
aggregations:,
sort:
}

query_hash[:highlight] = highlight if @highlight
Expand All @@ -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: [
Expand Down

0 comments on commit 3c9db10

Please sign in to comment.