Convert Lucene BooleanQuery to ES BoolQueryBuilder


I'm porting some indices from lucene to ES.
I've managed to use


to parse old lucene string queries to elastic.
However I can't seem to find a way to use Lucene's BooleanQuery with Elastic's BooleanQueryBuilder.

SearchRequest searchRequest = new SearchRequest(INDEX_NAME); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); BoolQueryBuilder mainQuery = new BoolQueryBuilder();

QueryStringQueryBuilder stringQueryBuilder = QueryBuilders.queryStringQuery(queryString); mainQuery.must(stringQueryBuilder);
mainQuery.must( lucene BooleanQuery here) ; searchSourceBuilder.query(mainQuery); searchRequest.source(searchSourceBuilder);

Could this be achieved or am I better off rewriting the code which builds the Lucene BooleanQuery using Elastic Search BooleanQueryBuilder?

Thank you for your time

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.