# Best practices when creating a complex index through the Java API

**URL:** <https://discuss.elastic.co/t/best-practices-when-creating-a-complex-index-through-the-java-api/29824>\
**Category:** Elasticsearch\
**Created:** [September 23, 2015, 5:56am UTC](https://discuss.elastic.co/t/best-practices-when-creating-a-complex-index-through-the-java-api/29824 "2015-09-23T05:56:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guill/32/4779_2.png) [@Guill](https://discuss.elastic.co/u/Guill)\
**Post date:** [September 23, 2015, 5:56am UTC](https://discuss.elastic.co/t/best-practices-when-creating-a-complex-index-through-the-java-api/29824/1 "2015-09-23T05:56:33Z")

</div>

Hello !  
I am creating fairy complex indexes though the java API - with a different tokenizer and a few fields that are non-analysed ( to perform alphabetic ordering ).  
Currently I am manually creating a Json file using the jsonBuilder for the tokenizer/analisys part and the specific fields I am adding a mapping and using setSource to another jsonBuilder built file.  
Is does work, but I wonder if this is the best way to do it, or if I should do it differently, I created a simple project to run some test - [https://github.com/GMelo/ElasticSearchInvestigation](https://github.com/GMelo/ElasticSearchInvestigation) Any help or information on previous experience is greatly appreciated.  
Thanks !

---

<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:48pm UTC](https://discuss.elastic.co/t/best-practices-when-creating-a-complex-index-through-the-java-api/29824/2 "2017-07-05T23:48:35Z")

</div>

Closed on July 5, 2017, 11:48pm UTC


