Closed
Description
Petar Tahchiev opened DATAES-467 and commented
Hello all.. with spring-boot-parent 2.0.2.RELEASE my code works fine, however with 2.0.3-BUILD-SNAPSHOT I get this error from elasticsearch:
2018-06-14 10:43:38,845 org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/storefront].[dispatcherServlet] [https-jsse-nio-127.0.0.1-8112-exec-4] ERROR: Servlet.service() for servlet [dispatcherServlet] in context with path [/storefront] threw exception [Request processing failed; nested exception is Failed to execute phase [dfs], all shards failed; shardFailures {[b8hjxXp7S5m9PNcIMBRRdg][products][0]: RemoteTransportException[[b8hjxXp][local[1]][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[No mapping found for [_score] in order to sort on]; }{[b8hjxXp7S5m9PNcIMBRRdg][products][1]: RemoteTransportException[[b8hjxXp][local[1]][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[No mapping found for [_score] in order to sort on]; }{[b8hjxXp7S5m9PNcIMBRRdg][products][2]: RemoteTransportException[[b8hjxXp][local[1]][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[No mapping found for [_score] in order to sort on]; }{[b8hjxXp7S5m9PNcIMBRRdg][products][3]: RemoteTransportException[[b8hjxXp][local[1]][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[No mapping found for [_score] in order to sort on]; }{[b8hjxXp7S5m9PNcIMBRRdg][products][4]: RemoteTransportException[[b8hjxXp][local[1]][indices:data/read/search[phase/dfs]]]; nested: QueryShardException[No mapping found for [_score] in order to sort on]; }] with root cause
[products/ppPVwKKeSkmIZQ2Y-_tEpQ] QueryShardException[No mapping found for [_score] in order to sort on]
at org.elasticsearch.search.sort.FieldSortBuilder.build(FieldSortBuilder.java:262)
at org.elasticsearch.search.sort.SortBuilder.buildSort(SortBuilder.java:156)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:634)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:485)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:461)
After googling I found this: https://discuss.elastic.co/t/sort-by--score-error-in-es5-1-1/71340/2
where it says: I‘m using the java api,and found that ’SortBuilders has new function call scoreSort,i use this solve the problem(original use fieldSort with "_score").
I use the spring-data API like this:
new Sort(order.getDirection(), "_score");
perhaps you need a new if the customer is trying to sort on _score
don't use FieldSort but instead the new way scoreSort
Referenced from: pull request #209, and commits 020b5e1, 37bc97d, ba3eba5, b51a370
Backported to: 3.0.9 (Kay SR9)