# How to create an index with the JavaScript API?

**URL:** <https://discuss.elastic.co/t/how-to-create-an-index-with-the-javascript-api/17609>\
**Category:** Elasticsearch\
**Created:** [May 20, 2014, 4:29am UTC](https://discuss.elastic.co/t/how-to-create-an-index-with-the-javascript-api/17609 "2014-05-20T04:29:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![el1](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@el1](https://discuss.elastic.co/u/el1)\
**Post date:** [May 20, 2014, 4:29am UTC](https://discuss.elastic.co/t/how-to-create-an-index-with-the-javascript-api/17609/1 "2014-05-20T04:29:18Z")

</div>

I would like to store a field in my index but do not get it work with  
JavaScript, well CoffeeScript:

INDEX = "myindex"  
exports.createIndexAd = () -\>  
client.indices.create  
index:  
INDEX  
type:  
'thing'  
mappings:  
INDEX:  
properties:  
url:  
type: 'string'  
store: 'yes'  
analyzer: 'keyword'

I get no error when I create the index, but the field 'url' is not stored  
when I index a document.

I tried this based on the documentation  
([http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-indices-create](http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-indices-create))  
but I do not understand it. Can anyone point me to an example how to create  
an index with JavaScript?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/103bbdc1-c4a1-4c27-88cf-c253d7b53e89%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/103bbdc1-c4a1-4c27-88cf-c253d7b53e89%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:28am UTC](https://discuss.elastic.co/t/how-to-create-an-index-with-the-javascript-api/17609/2 "2017-07-06T01:28:19Z")

</div>


