Skip to content

Commit

Permalink
Make _ID field always searchable (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
aprudhomme authored Sep 27, 2024
1 parent 49a8f92 commit 6dd6085
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ protected void setSearchProperties(FieldType fieldType, Field requestField) {
fieldType.setTokenized(false);
}

@Override
public boolean isSearchable() {
return true;
}

/**
* Store the docvalues if it's requested and store the string value in the document
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,26 @@ public void testStoredFields() {
assertEquals(1, hit.getFieldsOrThrow("id").getFieldValueCount());
assertEquals("3", hit.getFieldsOrThrow("id").getFieldValue(0).getTextValue());
}

@Test
public void testAlwaysSearchable() {
SearchResponse response =
getGrpcServer()
.getBlockingStub()
.search(
SearchRequest.newBuilder()
.setIndexName(DEFAULT_TEST_INDEX)
.setTopHits(3)
.addRetrieveFields("id")
.setQuery(
Query.newBuilder()
.setTermQuery(
TermQuery.newBuilder().setField("id").setTextValue("2").build())
.build())
.build());
assertEquals(1, response.getHitsCount());
SearchResponse.Hit hit = response.getHits(0);
assertEquals(1, hit.getFieldsOrThrow("id").getFieldValueCount());
assertEquals("2", hit.getFieldsOrThrow("id").getFieldValue(0).getTextValue());
}
}

0 comments on commit 6dd6085

Please sign in to comment.