How to copy boolQueryBuilder?

I have a usecase where I have a boolQueryBuilder which is common across different type of queries.

Now for different queries, I need to add a different must() to the boolQueryBuilder.

basically, say i have a common boolQueryBuilder which is built to filter books with certain tags. Now among these when i get a request to select specific type1/type2.
I have to do,
boolQueryBuilder.must(type1) for request1
boolQueryBuilder.must(type2) for request2 (which shouldnt have type1)

I tried deepcopy , serialize and deserialize but they are very very slow takes ~3seconds

I need type1 along with the tags in request1, and type2 along with tags in request2.

What is the better way to make use of the common builder i have instead of re-building the common queries again and again?

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