Skip to content

Commit

Permalink
remove use of deprecated SolrIndexSearcher.search variant (#2662)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9d2387f)
  • Loading branch information
cpoerschke committed Sep 6, 2024
1 parent ff9f6ac commit 1c29911
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,14 @@ public void testMinExactCount() {

private void assertMatchesEqual(int expectedCount, SolrIndexSearcher searcher, QueryCommand cmd)
throws IOException {
QueryResult qr = new QueryResult();
searcher.search(qr, cmd);
QueryResult qr = searcher.search(cmd);
assertEquals(expectedCount, qr.getDocList().matches());
assertEquals(TotalHits.Relation.EQUAL_TO, qr.getDocList().hitCountRelation());
}

private QueryResult assertMatchesGreaterThan(
int expectedCount, SolrIndexSearcher searcher, QueryCommand cmd) throws IOException {
QueryResult qr = new QueryResult();
searcher.search(qr, cmd);
QueryResult qr = searcher.search(cmd);
assertTrue(
"Expecting returned matches to be greater than "
+ expectedCount
Expand Down Expand Up @@ -182,7 +180,7 @@ public void testLowMinExactCountWithQueryResultCache() throws IOException {
searcher -> {
QueryCommand cmd = createBasicQueryCommand(NUM_DOCS / 2, 10, "field1_s", "foo");
cmd.clearFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
searcher.search(new QueryResult(), cmd);
searcher.search(cmd);
assertMatchesGreaterThan(NUM_DOCS, searcher, cmd);
return null;
});
Expand All @@ -194,7 +192,7 @@ public void testHighMinExactCountWithQueryResultCache() throws IOException {
searcher -> {
QueryCommand cmd = createBasicQueryCommand(NUM_DOCS, 2, "field1_s", "foo");
cmd.clearFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
searcher.search(new QueryResult(), cmd);
searcher.search(cmd);
assertMatchesEqual(NUM_DOCS, searcher, cmd);
return null;
});
Expand Down Expand Up @@ -278,8 +276,7 @@ private void implTestReranking(
cmd.setQuery(new FixedScoreReRankQuery(cmd.getQuery(), expectedScore));
}

final QueryResult qr = new QueryResult();
searcher.search(qr, cmd);
final QueryResult qr = searcher.search(cmd);

// check score for the first document
final DocIterator iter = qr.getDocList().iterator();
Expand Down
6 changes: 2 additions & 4 deletions solr/core/src/test/org/apache/solr/search/TestFiltering.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ public void testLiveDocsSharing() throws Exception {
cmd.setQuery(QParser.getParser(qstr, null, req).getQuery());
cmd.setLen(random().nextInt(30));
cmd.setNeedDocSet(true);
QueryResult res = new QueryResult();
searcher.search(res, cmd);
QueryResult res = searcher.search(cmd);
set = res.getDocSet();
assertSame(set, live);

cmd.setQuery(QParser.getParser(qstr + " OR id:0", null, req).getQuery());
cmd.setFilterList(QParser.getParser(qstr + " OR id:1", null, req).getQuery());
res = new QueryResult();
searcher.search(res, cmd);
res = searcher.search(cmd);
set = res.getDocSet();
assertSame(set, live);
}
Expand Down

0 comments on commit 1c29911

Please sign in to comment.