Skip to content

Commit

Permalink
HSEARCH-2422 Always compute scores when projecting on the score Elast…
Browse files Browse the repository at this point in the history
…icsearch
  • Loading branch information
yrodiere authored and Sanne committed Nov 28, 2016
1 parent b3095d9 commit 1c50cd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ private IndexSearcher() {
completeQuery.add( "aggregations", facets );
}

if ( projectedFields != null ) {
for ( String field : projectedFields ) {
if ( ElasticsearchProjectionConstants.SCORE.equals( field ) ) {
// Make sure to compute scores even if we don't sort by relevance
completeQuery.addProperty( "track_scores", true );
break;
}
}
}

// Initialize the sortByDistanceIndex to detect if the results are sorted by distance and the position
// of the sort
sortByDistanceIndex = getSortByDistanceIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ public void testProjectionWithList() throws Exception {
}

@Test
@Category(ElasticsearchSupportInProgress.class) // HSEARCH-2422 Error when projecting on the score while not sorting by relevance
public void testProjectionOnScoreWithoutRelevanceSort() throws Exception {
FullTextSession s = Search.getFullTextSession( openSession() );
prepEmployeeIndex( s );
Expand Down

0 comments on commit 1c50cd2

Please sign in to comment.