I would like to build a query to elasticsearch using search criteria from a html form. I have several input fields on the html page. For example, if the user fill two of these fields I could write :
BoolQueryBuilder query = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("archivo", "archivo1"))
.must(QueryBuilders.termQuery("nombre", "documento1"));
But... what if the user fill three fields I could have :
BoolQueryBuilder query = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("archivo", "archivo1"))
.must(QueryBuilders.termQuery("nombre", "documento1"))
.must(QueryBuilders.termQuery("third", "test"));
Is there any way to dinamicall build this kind of queries?