hi i am trying to do a search where i can find specific files using elastic search. This is my java client:
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.5.3</version>
</dependency>
I prepared a query as follows:
private static Query getQueryByStatus() {
BoolQuery boolQuery = BoolQuery.of(b -> b
.should(qb -> qb.match(m -> m.field("fileType").query("WAIT_EXP")))
.should(qb -> qb.match(m -> m.field("fileType").query("EXP")))
);
return boolQuery._toQuery();
}
Query testQuery = getQueryByStatus();
response = client.search(s -> s
.index(fileIndex)
.from(filterDto.getPage() * filterDto.getSize())
.size(filterDto.getSize())
.query(q -> q
.bool(b -> b
.must(matchCompany)
.must(matchByWords)
.should(testQuery)
)
),
SearchData.class
);
My expectation here is that it finds files with filetype exp or wait_exp, but elastic brings them as well as unrelated files. Unfortunately, I could not see any clear explanation on the subject in the client's document I used.