A
A
ArFeRR2014-07-09 16:53:06
PHP
ArFeRR, 2014-07-09 16:53:06

How to convert the WHERE part of a SQL query to a filter for ElasticSearch?

Help turn the below sql query condition into an ElasticSearch bool filter:
WHERE (
option = "weight" AND value = "50kg"
)
OR (
option = "weight" AND value = "500kg"
)
AND (
option = "magic" AND value = " no"
)
I wrote AND filters for internal conditions between option and value. Now I need to put these AND filters inside other filters. How to do it?
I tried using BoolFilter (Elastica.io library, language - php)
$boolFilter = new \Elastica\Filter\Bool();
$boolFilter->addShould($innerFilterAnd1);
$boolFilter->addShould($innerFilterAnd2);
$boolFilter->addMust($innerFilterAnd3);
returns an empty dataset.
Please, help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question