# Mysql data mapping for Elasticseach

**URL:** <https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239>\
**Category:** Elasticsearch\
**Created:** [February 19, 2016, 12:36pm UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239 "2016-02-19T12:36:27Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)\
**Post date:** [March 1, 2016, 10:36am UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239/21 "2016-03-01T10:36:15Z")

</div>

It shows that the input value was tokenized properly as expeced from an edge ngram tokenizer. Again, this is good for the index and searching.

---

<div class="post-metadata">

**Author:** ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)\
**Post date:** [March 1, 2016, 10:46am UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239/22 "2016-03-01T10:46:40Z")

</div>

I don't think using "nested" here helps at all. For more info on how to use nested object, see the link below

[https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-objects.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-objects.html)

If your goal is to modify the value (ie. YDDD) to an array of ["Y", "YD"] then index the value, I think the data is indexed in one of the formats below

- { "islem": ["Y", "YD"] }
- {"islem": [{"value": "Y"}, {"value": "YD"}] } \<-- nested mapping can be used here

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [March 9, 2016, 2:20pm UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239/23 "2016-03-09T14:20:52Z")

</div>

I tried nested mapping but it dosen't work. Because my mysql data is not appropriate for nested. So I did string mapping . It work true. Thank you so much.  
I got my last one more question. I want to run a query like "starts with". So I use edge n gram.

```
PUT /ihaleler
    {
        "settings" : {
            "analysis" : {
                "analyzer" : {
                    "my_edge_ngram_analyzer" : {
                        "tokenizer" : "my_edge_ngram_tokenizer"
                    }
                },
                "tokenizer" : {
                    "my_edge_ngram_tokenizer" : {
                        "type" : "edgeNGram",
                        "min_gram" : "1",
                        "max_gram" : "2",
                        "token_chars": ["letter"]
                    }}}}}

```

and my filter.php:

```
unset($filter_islem);
    if(isset($_GET['islem'])){
        $filter_islem['match_phrase']['islem']=$_GET['islem'];
    }
if(is_array($filter_islem)){
    $searchParams['body']['query']['bool']['must']['and'][]=$filter_islem;

```

}

**- My first query:**

`http://localhost:9200/ihaleler/_search?q=islem:*D`

\*\* results:\*\*

```
found=280 record

```

**-My Other query:**  
`http://10.0.2.15:8080/filter.php?islem=*D`

**result:**

```
no result. 
found=0 record

```

What can I do for correct operation of the other query?

---

<div class="post-metadata">

**Author:** ![Kiran\_S\_N](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@Kiran\_S\_N](https://discuss.elastic.co/u/Kiran_S_N)\
**Post date:** [March 10, 2016, 10:25am UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239/24 "2016-03-10T10:25:00Z")

</div>

use GET method and try for it..

---

<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 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239/25 "2017-07-05T23:09:34Z")

</div>



[Previous page](https://discuss.elastic.co/t/mysql-data-mapping-for-elasticseach/42239.md?page=1)
