Skip to content

Commit

Permalink
Merge branch 'hotfix/1.33.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Dec 7, 2023
2 parents a2644ea + 91dba17 commit b528654
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions whelk-core/src/main/groovy/whelk/search/ESQuery.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,13 @@ class ESQuery {
def (String field, String sortOrder) = getFieldAndSortOrder(sortParam)
String termPath = getInferredTermPath(field)
Map clause = [(termPath): ['order': sortOrder]]
// FIXME: this should be based on if the path is inside nested, not hardcoded to hasTitle.mainTitle
// what about the filter condition then?
if (field == 'hasTitle.mainTitle' || field == 'hasTitle.mainTitle.keyword') {
clause[termPath]['nested_path'] = 'hasTitle'
clause[termPath]['nested_filter'] = ['term': ['hasTitle.@type': 'Title']]
clause[termPath]['nested'] = [
'path': 'hasTitle',
'filter': ['term': ['hasTitle.@type': 'Title']]
]
}
return clause
}
Expand Down
3 changes: 1 addition & 2 deletions whelk-core/src/test/groovy/whelk/search/ESQuerySpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class ESQuerySpec extends Specification {
// `bar` has a keyword field in the mappings
['_sort': ['foo,-bar']] | [['foo': ['order': 'asc']], ['bar.keyword': ['order': 'desc']]]
['_sort': ['hasTitle.mainTitle']] | [['hasTitle.mainTitle': ['order': 'asc',
'nested_path': 'hasTitle',
'nested_filter': ['term': ['hasTitle.@type': 'Title']]]]]
'nested': ['path': 'hasTitle', 'filter': ['term': ['hasTitle.@type': 'Title']]]]]]
}

def "should get site filter"() {
Expand Down

0 comments on commit b528654

Please sign in to comment.