# Is ElasticSearch the Right Tool for This

**URL:** <https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074>\
**Category:** Elasticsearch\
**Created:** [April 18, 2014, 6:37am UTC](https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074 "2014-04-18T06:37:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_4](https://avatars.discourse-cdn.com/v4/letter/p/73ab20/32.png) [@Paul\_4](https://discuss.elastic.co/u/Paul_4)\
**Post date:** [April 18, 2014, 6:37am UTC](https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074/1 "2014-04-18T06:37:19Z")

</div>

Hi,

We're looking to move our infrastructure to ElasticSearch and I have some  
concerns. We plan on using this more as a database and less than a search  
engine. I know there are some companies out there that are doing this, but  
I have some queries that, with one SQL command I can get the results I  
need, whereas ElasticSearch I would need to do filters of queries, etc.

An example, using SQL parlance, how would I do the following statement:

select col1, col2 from mytable where col3 in ["", "some", "value] and col4  
in ["another", "set", "", "values"] and col5 = "hello" and col6 not in  
"world" order by col7.

This is an example of some data I would be querying, and I would be  
performing 1000's of queries at a time.

So my question: Can ElasticSearch do this and if so, how can I do the  
above query.

--  
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/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [April 18, 2014, 8:58am UTC](https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074/2 "2014-04-18T08:58:25Z")

</div>

Sent from my iPhone

On 18-Apr-2014, at 12:07 PM, Paul [paulj3000@gmail.com](mailto:paulj3000@gmail.com) wrote:

> Hi,
> 
> We're looking to move our infrastructure to Elasticsearch and I have some concerns. We plan on using this more as a database and less than a search engine. I know there are some companies out there that are doing this, but I have some queries that, with one SQL command I can get the results I need, whereas Elasticsearch I would need to do filters of queries, etc.
> 
> An example, using SQL parlance, how would I do the following statement:
> 
> select col1, col2 from mytable where col3 in ["", "some", "value] and col4 in ["another", "set", "", "values"] and col5 = "hello" and col6 not in "world" order by col7.
> 
> This is an example of some data I would be querying, and I would be performing 1000's of queries at a time.
> 
> ## So my question: Can Elasticsearch do this and if so, how can I do the above query.
> 
> 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/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/5519FAE2-009C-40E7-BED8-0F344F6A22BC%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/5519FAE2-009C-40E7-BED8-0F344F6A22BC%40gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [April 18, 2014, 10:43am UTC](https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074/3 "2014-04-18T10:43:42Z")

</div>

Hiya

It's a bit more verbose, but yes you can do queries like that easily. I've  
assumed that all of your fields are "exact value" not\_analyzed string  
fields, rather than full text fields:

GET /\_search  
{  
"\_source": ["col1", "col2"],  
"query": {  
"filtered": {  
"filter": {  
"bool": {  
"must": [  
{  
"bool": {  
"should": [  
{ "terms": { "col3": ["some", "value"]}},  
{ "missing": { "field": "col3" }}  
]  
}  
},  
{  
"bool": {  
"should": [  
{ "terms": { "col4": ["another", "set", "values"]}},  
{ "missing": { "field": "col4" }}  
]  
}  
},  
{ "term": { "col5": "hello" }}  
],  
"must\_not": [  
{ "term": { "col6": "world" }}  
]  
}  
}  
}  
},  
"sort": "col7"  
}

All of those lookups use filters, so would be cached, making all future  
executions very fast indeed.

On 18 April 2014 08:37, Paul [paulj3000@gmail.com](mailto:paulj3000@gmail.com) wrote:

> Hi,
> 
> We're looking to move our infrastructure to Elasticsearch and I have some  
> concerns. We plan on using this more as a database and less than a search  
> engine. I know there are some companies out there that are doing this, but  
> I have some queries that, with one SQL command I can get the results I  
> need, whereas Elasticsearch I would need to do filters of queries, etc.
> 
> An example, using SQL parlance, how would I do the following statement:
> 
> select col1, col2 from mytable where col3 in ["", "some", "value] and col4  
> in ["another", "set", "", "values"] and col5 = "hello" and col6 not in  
> "world" order by col7.
> 
> This is an example of some data I would be querying, and I would be  
> performing 1000's of queries at a time.
> 
> So my question: Can Elasticsearch do this and if so, how can I do the  
> above query.
> 
> --  
> 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/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a59fcffe-5671-4ee0-a6bf-d49aedd3189b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAPt3XKSKZ4uzfD3BuFtWqpnAg97Yc7m4cEtGBBbrYOoN5x7n0A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKSKZ4uzfD3BuFtWqpnAg97Yc7m4cEtGBBbrYOoN5x7n0A%40mail.gmail.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:35am UTC](https://discuss.elastic.co/t/is-elasticsearch-the-right-tool-for-this/17074/4 "2017-07-06T01:35:04Z")

</div>


