# Converting from MySQL

**URL:** <https://discuss.elastic.co/t/converting-from-mysql/2843>\
**Category:** Elasticsearch\
**Created:** [March 9, 2010, 6:08pm UTC](https://discuss.elastic.co/t/converting-from-mysql/2843 "2010-03-09T18:08:57Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [March 9, 2010, 6:08pm UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/1 "2010-03-09T18:08:57Z")

</div>

Hiya

I'm in the process of converting my queries from MySQL to ElasticSearch,  
and would like to know if my mapping makes sense.

I've identified 6 common types of data that I want to store:

- ID - a single integer/long
- enum - a single value string, eg status: active | inactive |  
pending
- text - freeform text, names, email addresses etc
- date - dates, datetimes, times
- ID's - multiple ID's, eg a list of object ancestor IDs
- enum's - multiple enums, eg tags for a blog

Mappings:

- ID - { type: long }
- enum - { type: string, index: not\_analyzed }
- text - { type: string, analyzer: standard }
- date - { type: date | datetime etc }  
ï»¿ - ID's - { type string, analyzer: whitespace }  
ï»¿ - enum's - { type string, analyzer: whitespace }

So when searching for eg tags ( == enum's), I'd do something like:

{  
bool: {  
should: [  
ï»¿ { term: { tag: 'foo' }},  
ï»¿ { term: { tag: 'bar' }}  
]  
}}

Does this look right?

thanks

Clint

--  
Web Announcements Limited is a company registered in England and Wales,  
with company number 05608868, with registered address at 10 Arvon Road,  
London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 9, 2010, 6:21pm UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/2 "2010-03-09T18:21:37Z")

</div>

Looks good. A point about IDs, if you can have then as a JSON array of  
each id, then its better to use it and then use not\_analyzed for it.  
Similar, you can do the same for enum's.

-shay.banon

On Tue, Mar 9, 2010 at 8:08 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Hiya
> 
> I'm in the process of converting my queries from MySQL to Elasticsearch,  
> and would like to know if my mapping makes sense.
> 
> I've identified 6 common types of data that I want to store:
> 
> - ID - a single integer/long
> - enum - a single value string, eg status: active | inactive |  
> pending
> - text - freeform text, names, email addresses etc
> - date - dates, datetimes, times
> - ID's - multiple ID's, eg a list of object ancestor IDs
> - enum's - multiple enums, eg tags for a blog
> 
> Mappings:
> 
> - ID - { type: long }
> - enum - { type: string, index: not\_analyzed }
> - text - { type: string, analyzer: standard }
> - date - { type: date | datetime etc }  
> ﻿ - ID's - { type string, analyzer: whitespace }  
> ﻿ - enum's - { type string, analyzer: whitespace }
> 
> So when searching for eg tags ( == enum's), I'd do something like:
> 
> {  
> bool: {  
> should: [  
> ﻿ { term: { tag: 'foo' }},  
> ﻿ { term: { tag: 'bar' }}  
> ]  
> }}
> 
> Does this look right?
> 
> thanks
> 
> Clint
> 
> --  
> Web Announcements Limited is a company registered in England and Wales,  
> with company number 05608868, with registered address at 10 Arvon Road,  
> London, N5 1PR.

---

<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:** [March 9, 2010, 6:30pm UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/3 "2010-03-09T18:30:01Z")

</div>

On Tue, 2010-03-09 at 20:21 +0200, Shay Banon wrote:

> Looks good. A point about IDs, if you can have then as a JSON array  
> of each id, then its better to use it and then use not\_analyzed for  
> it. Similar, you can do the same for enum's.

Ah fantastic! I had no idea that you could do that - I didn't see it  
mentioned in the docs.

--  
Web Announcements Limited is a company registered in England and Wales,  
with company number 05608868, with registered address at 10 Arvon Road,  
London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 9, 2010, 10:34pm UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/4 "2010-03-09T22:34:25Z")

</div>

Its here:  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/array\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/array_type/)

-shay.banon

On Tue, Mar 9, 2010 at 8:30 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> On Tue, 2010-03-09 at 20:21 +0200, Shay Banon wrote:
> 
> > Looks good. A point about IDs, if you can have then as a JSON array  
> > of each id, then its better to use it and then use not\_analyzed for  
> > it. Similar, you can do the same for enum's.
> 
> Ah fantastic! I had no idea that you could do that - I didn't see it  
> mentioned in the docs.
> 
> --  
> Web Announcements Limited is a company registered in England and Wales,  
> with company number 05608868, with registered address at 10 Arvon Road,  
> London, N5 1PR.

---

<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:** [March 10, 2010, 11:13am UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/5 "2010-03-10T11:13:10Z")

</div>

On Wed, 2010-03-10 at 00:34 +0200, Shay Banon wrote:

> Its here:  
> [http://www.elasticsearch.com/docs/elasticsearch/mapping/array\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/array_type/)

Ah thanks - it should be added to the main page on  
[http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)

clint

> -shay.banon
> 
> On Tue, Mar 9, 2010 at 8:30 PM, Clinton Gormley  
> [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:  
> On Tue, 2010-03-09 at 20:21 +0200, Shay Banon wrote:  
> \> Looks good. A point about IDs, if you can have then as a  
> JSON array  
> \> of each id, then its better to use it and then use  
> not\_analyzed for  
> \> it. Similar, you can do the same for enum's.
> 
> ```
> Ah fantastic! I had no idea that you could do that - I didn't
> see it
> mentioned in the docs.
>     
> --
>     
> Web Announcements Limited is a company registered in England
> and Wales,
> with company number 05608868, with registered address at 10
> Arvon Road,
> London, N5 1PR.
> 
> ```

--  
Web Announcements Limited is a company registered in England and Wales,  
with company number 05608868, with registered address at 10 Arvon Road,  
London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 10, 2010, 11:55am UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/6 "2010-03-10T11:55:02Z")

</div>

Oops..., added.

On Wed, Mar 10, 2010 at 1:13 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> On Wed, 2010-03-10 at 00:34 +0200, Shay Banon wrote:
> 
> > Its here:  
> > [http://www.elasticsearch.com/docs/elasticsearch/mapping/array\_type/](http://www.elasticsearch.com/docs/elasticsearch/mapping/array_type/)
> 
> Ah thanks - it should be added to the main page on  
> [http://www.elasticsearch.com/docs/elasticsearch/mapping/](http://www.elasticsearch.com/docs/elasticsearch/mapping/)
> 
> clint
> 
> > -shay.banon
> > 
> > On Tue, Mar 9, 2010 at 8:30 PM, Clinton Gormley  
> > [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:  
> > On Tue, 2010-03-09 at 20:21 +0200, Shay Banon wrote:  
> > \> Looks good. A point about IDs, if you can have then as a  
> > JSON array  
> > \> of each id, then its better to use it and then use  
> > not\_analyzed for  
> > \> it. Similar, you can do the same for enum's.
> > 
> > ```
> > Ah fantastic! I had no idea that you could do that - I didn't
> > see it
> > mentioned in the docs.
> > 
> > --
> > 
> > Web Announcements Limited is a company registered in England
> > and Wales,
> > with company number 05608868, with registered address at 10
> > Arvon Road,
> > London, N5 1PR.
> > 
> > ```
> 
> --  
> Web Announcements Limited is a company registered in England and Wales,  
> with company number 05608868, with registered address at 10 Arvon Road,  
> London, N5 1PR.

---

<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, 4:25am UTC](https://discuss.elastic.co/t/converting-from-mysql/2843/7 "2017-07-06T04:25:21Z")

</div>


