SELECT * FROM table WHERE account_id = 128 AND city_id = 256;
My problem is that I do not know how to create groups with conditions, so my searches are always with AND / AND / AND condition, which ends up limiting the use of my data.
Is possible create a JSON to search data like this?
SELECT * FROM table WHERE account_id = 128 AND city_id = 256 AND (neighborhood_id = 512 OR street_id = 1024 AND (customer_active = true OR customer_new = true));
You could use the Lucene query syntax using the Query string query:
"query_string": {
"query": "account_id:128 AND city_id:256 AND (neighborhood_id:512 OR street_id:1024 AND (customer_active:true OR customer_new:true))"
}
You could, also, try the translate API from ES-SQL to give you an ES query given a certain SQL query :-). More about this API here.
In short you write something like this:
POST /_xpack/sql/translate
{
"query": "SELECT * FROM table WHERE account_id = 128 AND city_id = 256 AND (neighborhood_id = 512 OR street_id = 1024 AND (customer_active = true OR customer_new = true))"
}
And the plugin will answer with something like this:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.