Hello.
I want the hybrid search by using both the knn option and a query on the page below with java client.
With spring-boot 3.1.5 and elasticsarch-java 8.7.1 environment,
I made some codes as below, but seems like .withKnnQuery(knnQuery) condition is not processed. Is there any way?
MatchQuery matchQuery = new MatchQuery.Builder().field(textfield).query(searchText).boost(1.0f).build();
BoolQuery boolQuery = new BoolQuery.Builder().must(List.of(matchQuery._toQuery())).build();
TermsQuery termsQuery = new TermsQuery.Builder().field("ownerNm").terms(new TermsQueryField.Builder().value(List.of(FieldValue.of("luis"))).build()).build();
KnnQuery knnQuery = new KnnQuery.Builder()
.field("text_VEC")
.queryVector(queryEmbedding)
.numCandidates(100)
.k(10)
.boost(10.0f)
.filter(List.of(termsQuery._toQuery()))
.build();
Query searchQuery = NativeQuery.builder()
.withKnnQuery(knnQuery)
.withQuery(boolQuery._toQuery())
.withSearchType(null)
.withMaxResults(5)
.build();
SearchHits<TetstIndex> searchHits = operations.search(searchQuery, TestIndex.class);