# JDBC Importer - Custom mapping for single field

**URL:** <https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263>\
**Category:** Elasticsearch\
**Created:** [September 22, 2016, 1:43pm UTC](https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263 "2016-09-22T13:43:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marv](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@marv](https://discuss.elastic.co/u/marv)\
**Post date:** [September 22, 2016, 1:43pm UTC](https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263/1 "2016-09-22T13:43:50Z")

</div>

Hi,

I´m trying to index a Mantis MySql-database with Elasticsearch using the Elasticsearch JDBC Importer(which is a great tool by the way). The dynamic Mapping just works fine for me but I´m wondering if it is possible to map numerical values to a string value.

There is a status field for every Mantis issue, which is saved by long values from 10 to 90. Every number has a specific status, e.g:  
10 =\> new  
80 =\> resolved  
etc.

Im trying to visualize the status data via Kibana and therefore it would be nice to have the status as string value. Is it possible to with a custom mapping, analyzer or something like that?

I appreciate your help,  
Marv

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 22, 2016, 10:15pm UTC](https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263/2 "2016-09-22T22:15:38Z")

</div>

JDBC importer maps SQL types to JSON types and the JSON types are mapped to Elasticsearch.

The trick is to write a smart (and verbose) SQL statement that takes your number column and turns them into a string. For an example, see the MySQL CASE SQL expression

[https://dev.mysql.com/doc/refman/5.7/en/control-flow-functions.html#operator\_case](https://dev.mysql.com/doc/refman/5.7/en/control-flow-functions.html#operator_case)

```auto
SELECT CASE my_status_code
    WHEN 10 then 'new'
    WHEN 80 then 'resolved'
   ... 
  END as my_status_text
  ...     

```

---

<div class="post-metadata">

**Author:** ![marv](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@marv](https://discuss.elastic.co/u/marv)\
**Post date:** [September 26, 2016, 7:53am UTC](https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263/3 "2016-09-26T07:53:23Z")

</div>

Thank you Jörg. This worked for me.

---

<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, 10:17pm UTC](https://discuss.elastic.co/t/jdbc-importer-custom-mapping-for-single-field/61263/4 "2017-07-05T22:17:22Z")

</div>


