Skip to content

Commit

Permalink
Fix misalignment in SearchCollection and SimpleImpactSearcher impleme…
Browse files Browse the repository at this point in the history
…ntations (#2165) - ref #2167
  • Loading branch information
AileenLin committed Aug 11, 2023
1 parent e59f9e7 commit 862bd27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/io/anserini/search/SimpleImpactSearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,8 @@ public Result[] search(Map<String, Integer> encoded_q, int k) throws IOException
public Result[] search(String q, int k) throws IOException, OrtException {
// make encoded query from raw query
Map<String, Integer> encoded_q = encodeWithOnnx(q);
Query query = generator.buildQuery(Constants.CONTENTS, analyzer, q);

String encodedQuery = encodeWithOnnx(encoded_q);
Query query = generator.buildQuery(Constants.CONTENTS, analyzer, encodedQuery);
return _search(query, encodedQuery, k);
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/java/io/anserini/search/SimpleImpactSearcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,23 @@ public void testSearch5() throws Exception {
isearcher_rm3.close();
}

@Test
public void testSearch6() throws Exception {
// test the expanded query result should be diff with testSearch5
SimpleImpactSearcher searcher = new SimpleImpactSearcher(super.tempDir1.toString());
searcher.set_onnx_query_encoder("UniCoil");

Result[] results;

String query = "this is a a a a a test";
results = searcher.search(query, 1);

assertEquals(1, results.length);
assertEquals("doc3", results[0].docid);
assertEquals(2, results[0].lucene_docid);
assertEquals(130.0, results[0].score, 10e-5);

searcher.close();
}

}

0 comments on commit 862bd27

Please sign in to comment.