# Question about java api with multiple filters combination

**URL:** <https://discuss.elastic.co/t/question-about-java-api-with-multiple-filters-combination/16442>\
**Category:** Elasticsearch\
**Created:** [March 18, 2014, 11:24pm UTC](https://discuss.elastic.co/t/question-about-java-api-with-multiple-filters-combination/16442 "2014-03-18T23:24:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anng](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@anng](https://discuss.elastic.co/u/anng)\
**Post date:** [March 18, 2014, 11:24pm UTC](https://discuss.elastic.co/t/question-about-java-api-with-multiple-filters-combination/16442/1 "2014-03-18T23:24:55Z")

</div>

Hi,

I have 3 different filters OrFilterBuilder, RangeFilterBuilder,  
PrefixFilterBuilder. I'd like to combine those filter and have an "and"  
relation among them. FilterBuilders.andFilter(filter1, filter2, filter3)  
would work; however, filter1, filter2, filter3 could be null. Is there a  
better way of combining those rather than nested if else?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d6a88417-0b44-4212-be5a-bf09d5390e03%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d6a88417-0b44-4212-be5a-bf09d5390e03%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:42am UTC](https://discuss.elastic.co/t/question-about-java-api-with-multiple-filters-combination/16442/2 "2017-07-06T01:42:22Z")

</div>

Closed on July 6, 2017, 1:42am UTC


