# Convert mysql to elasticsearch

**URL:** https://discuss.elastic.co/t/convert-mysql-to-elasticsearch/120030
**Category:** Elasticsearch
**Created:** [February 15, 2018, 4:52pm UTC](https://discuss.elastic.co/t/convert-mysql-to-elasticsearch/120030 "2018-02-15T16:52:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![PauloViegas](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@PauloViegas](https://discuss.elastic.co/u/PauloViegas)
#### Post date: [February 15, 2018, 4:52pm UTC](https://discuss.elastic.co/t/convert-mysql-to-elasticsearch/120030/1 "2018-02-15T16:52:39Z")

</div>

I try to convert a sql search query to elasticsearch query from elasticsearch documantation, but samething are worng anyone can help me?

I have a document with same fields like age and city. i need search a people with 40 years old and don't live in the city Umapine.

My mysql code is samething like this:

```
SELECT *
FROM bank
WHERE age = 40 and city != Umapine

```

and in elasticsearch code i try to do samething like this:

```
{
   "query" : {
       "constant_score" : { 
         "filter" : {
            "bool" : {
            	"should" : { "term" : {"age" : 40} },
                "must_not" : { "term" : {"city" : "Umapine"} }
           }
         }
      }
   }
}

```

But samething are worng, anyone know what is worng?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 15, 2018, 6:44pm UTC](https://discuss.elastic.co/t/convert-mysql-to-elasticsearch/120030/2 "2018-02-15T18:44:27Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

Also you did not share what result you get. Neither the elasticsearch version.

Anyway, try with `umapine` instead of `Umapine`.

---

<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: [March 15, 2018, 6:44pm UTC](https://discuss.elastic.co/t/convert-mysql-to-elasticsearch/120030/3 "2018-03-15T18:44:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
