Skip to content

Commit 84ec43d

Browse files
committed
Reduce MAX_TOP_N_INDEX_READ_SIZE to 50, sort by desc latency (opensearch-project#281)
Signed-off-by: David Zane <[email protected]> (cherry picked from commit a876495)
1 parent 4b24828 commit 84ec43d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/opensearch/plugin/insights/core/reader/LocalIndexReader.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
import org.opensearch.plugin.insights.rules.model.SearchQueryRecord;
3535
import org.opensearch.search.SearchHit;
3636
import org.opensearch.search.builder.SearchSourceBuilder;
37+
import org.opensearch.search.sort.SortBuilders;
38+
import org.opensearch.search.sort.SortOrder;
3739

3840
/**
3941
* Local index reader for reading query insights data from local OpenSearch indices.
4042
*/
4143
public final class LocalIndexReader implements QueryInsightsReader {
42-
private final static int MAX_TOP_N_INDEX_READ_SIZE = 1000;
44+
private final static int MAX_TOP_N_INDEX_READ_SIZE = 50;
4345
/**
4446
* Logger of the local index reader
4547
*/
@@ -128,6 +130,7 @@ public List<SearchQueryRecord> read(final String from, final String to, String i
128130
query.must(QueryBuilders.matchQuery("id", id));
129131
}
130132
searchSourceBuilder.query(query);
133+
searchSourceBuilder.sort(SortBuilders.fieldSort("measurements.latency.number").order(SortOrder.DESC));
131134
searchRequest.source(searchSourceBuilder);
132135
try {
133136
SearchResponse searchResponse = client.search(searchRequest).actionGet();

0 commit comments

Comments
 (0)