Skip to content

Commit

Permalink
don't require parms
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-4 committed Jan 23, 2025
1 parent 1ed836e commit 37597ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/main/java/io/anserini/server/ControllerV1_0.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public Map<String, Object> searchIndex(@PathVariable(value = "index", required =
@RequestParam(value = "hits", defaultValue = "10") int hits,
@RequestParam(value = "qid", defaultValue = "") String qid,
@RequestParam(value = "efSearch", defaultValue = "100") int efSearch,
@RequestParam(value = "encoder", required = true) String encoder,
@RequestParam(value = "queryGenerator", required = true) String queryGenerator) {
@RequestParam(value = "encoder", required = false) String encoder,
@RequestParam(value = "queryGenerator", required = false) String queryGenerator) {

if (index == null) {
index = DEFAULT_INDEX;
Expand All @@ -61,10 +61,8 @@ public Map<String, Object> searchIndex(@PathVariable(value = "index", required =
throw new IllegalArgumentException("Index " + index + " not found!");
}

if (index.contains(".hnsw")) {
if (encoder == null || queryGenerator == null) {
throw new IllegalArgumentException("HNSW indexes require both 'encoder' and 'queryGenerator' parameters");
}
if (index.contains(".hnsw") && (encoder == null || queryGenerator == null)) {
throw new IllegalArgumentException("HNSW indexes require both 'encoder' and 'queryGenerator' parameters");
}

SearchService searchService = new SearchService(index);
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/io/anserini/server/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,8 @@ private HnswDenseSearcher.Args createHnswArgs(int efSearch, String encoder, Stri
HnswDenseSearcher.Args args = new HnswDenseSearcher.Args();
args.index = indexDir;
args.efSearch = efSearch;
args.queryGenerator = queryGenerator != null ? queryGenerator : DEFAULT_QUERY_GENERATOR;

// Attempt to get encoder from IndexInfo, or use provided encoder
if (encoder != null) {
args.encoder = encoder;
} else if (IndexInfo.contains(prebuiltIndex)) {
IndexInfo info = IndexInfo.get(prebuiltIndex);
args.encoder = info.model.substring(0, info.model.indexOf(" w/ HNSW"));
}
args.encoder = encoder;
args.queryGenerator = queryGenerator;
return args;
}

Expand Down

0 comments on commit 37597ff

Please sign in to comment.