# How to "translate" the "where" clause from sql query to elasticsearch filter

**URL:** <https://discuss.elastic.co/t/how-to-translate-the-where-clause-from-sql-query-to-elasticsearch-filter/18571>\
**Category:** Elasticsearch\
**Created:** [July 10, 2014, 9:13am UTC](https://discuss.elastic.co/t/how-to-translate-the-where-clause-from-sql-query-to-elasticsearch-filter/18571 "2014-07-10T09:13:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artem\_Frolov](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@Artem\_Frolov](https://discuss.elastic.co/u/Artem_Frolov)\
**Post date:** [July 10, 2014, 9:13am UTC](https://discuss.elastic.co/t/how-to-translate-the-where-clause-from-sql-query-to-elasticsearch-filter/18571/1 "2014-07-10T09:13:10Z")

</div>

Hello! I'm implementing the filter for the internet shop using elastic  
search. I have an EAV model in my RDBMS.

I have a WHERE clause in my SQL query, which have to be translated into the  
elasticsearch bool filter.It works just fine in my rdbms.

here's it is:

WHERE (option = "weight" AND value = "50kg")OR (option = "weight" AND value = "500kg")AND (option = "magic" AND value = "no")

I have written the AND filters for inner ANDs of query, but now I need to  
put them to the bool filter.

Tried to: (using elastica php library)

$boolFilter = new \Elastica\Filter\Bool();$boolFilter-\>addShould($innerFilterAnd1);$boolFilter-\>addShould($innerFilterAnd2);$boolFilter-\>addMust($innerFilterAnd3);

returns nothing.

Please, help!

--  
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/fb5db090-e087-4481-8d6d-3d1783543d85%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fb5db090-e087-4481-8d6d-3d1783543d85%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:16am UTC](https://discuss.elastic.co/t/how-to-translate-the-where-clause-from-sql-query-to-elasticsearch-filter/18571/2 "2017-07-06T01:16:52Z")

</div>


