mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-18 02:44:49 +00:00
Merge pull request #3009 from chilling/issue2986_scores
Fixed parsing of track_scores in RestSearchAction
This commit is contained in:
commit
b7cd8a64cd
@ -226,6 +226,13 @@ public class RestSearchAction extends BaseRestHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(request.hasParam("track_scores")) {
|
||||||
|
if (searchSourceBuilder == null) {
|
||||||
|
searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
}
|
||||||
|
searchSourceBuilder.trackScores(request.paramAsBoolean("track_scores", false));
|
||||||
|
}
|
||||||
|
|
||||||
String sSorts = request.param("sort");
|
String sSorts = request.param("sort");
|
||||||
if (sSorts != null) {
|
if (sSorts != null) {
|
||||||
if (searchSourceBuilder == null) {
|
if (searchSourceBuilder == null) {
|
||||||
|
@ -168,6 +168,31 @@ public class SimpleSortTests extends AbstractNodesTests {
|
|||||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
|
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIssue2986() {
|
||||||
|
try {
|
||||||
|
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
client.admin().indices().prepareCreate("test").execute().actionGet();
|
||||||
|
|
||||||
|
client.prepareIndex("test", "post", "1").setSource("{\"field1\":\"value1\"}").execute().actionGet();
|
||||||
|
client.prepareIndex("test", "post", "2").setSource("{\"field1\":\"value2\"}").execute().actionGet();
|
||||||
|
client.prepareIndex("test", "post", "3").setSource("{\"field1\":\"value3\"}").execute().actionGet();
|
||||||
|
|
||||||
|
client.admin().indices().prepareRefresh("test").execute().actionGet();
|
||||||
|
|
||||||
|
SearchResponse result = client.prepareSearch("test").setQuery(matchAllQuery()).setTrackScores(true).addSort("field1", SortOrder.ASC).execute().actionGet();
|
||||||
|
|
||||||
|
for (SearchHit hit : result.getHits()) {
|
||||||
|
assert !Float.isNaN(hit.getScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIssue2991() {
|
public void testIssue2991() {
|
||||||
for (int i = 1; i < 4; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user