# Using Java API to map, load and index

**URL:** <https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901>\
**Category:** Elasticsearch\
**Created:** [September 21, 2014, 8:28pm UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901 "2014-09-21T20:28:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arkerpay](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@arkerpay](https://discuss.elastic.co/u/arkerpay)\
**Post date:** [September 21, 2014, 8:28pm UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901/1 "2014-09-21T20:28:07Z")

</div>

Very new to elasticsearch, so please be kind.

Would like to find working code example in Java that:

(1) creates an index  
(2) creates a mapping  
(3) specifies an analyzer  
(4) converts text files to json  
(5) loads the json into elasticsearch

I have successfully created an index using curl and head. I successfully  
wrote a java program that converts (a directory of) text files to json and  
loads them into elasticsearch. However the mapping is implied and the  
analyzer is implied (default?). I would like to programmatically specify  
the index creation, mapping, and analysis.

My searches usually result in an example using curl or something off-topic.  
I suspect what I am trying to do is a very common task, could someone  
please point me to a working code example ?

arkerpay

--  
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/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 21, 2014, 8:40pm UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901/2 "2014-09-21T20:40:20Z")

</div>

You could give a look at [https://github.com/scrutmydocs/scrutmydocs](https://github.com/scrutmydocs/scrutmydocs) which basically does that.  
Or FSRiver: [https://github.com/dadoonet/fsriver](https://github.com/dadoonet/fsriver)

Also Elasticsearch unit tests are a good place to find Java code.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 sept. 2014 à 22:28, [arkerpay@gmail.com](mailto:arkerpay@gmail.com) a écrit :

Very new to elasticsearch, so please be kind.

Would like to find working code example in Java that:

(1) creates an index  
(2) creates a mapping  
(3) specifies an analyzer  
(4) converts text files to json  
(5) loads the json into elasticsearch

I have successfully created an index using curl and head. I successfully wrote a java program that converts (a directory of) text files to json and loads them into elasticsearch. However the mapping is implied and the analyzer is implied (default?). I would like to programmatically specify the index creation, mapping, and analysis.

My searches usually result in an example using curl or something off-topic. I suspect what I am trying to do is a very common task, could someone please point me to a working code example ?

## arkerpay

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/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/049F9A22-F98A-4916-AF02-EE19470EDCBB%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/049F9A22-F98A-4916-AF02-EE19470EDCBB%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![arkerpay](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@arkerpay](https://discuss.elastic.co/u/arkerpay)\
**Post date:** [September 21, 2014, 8:53pm UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901/3 "2014-09-21T20:53:55Z")

</div>

Appreciate the quick response! These are large projects. Could you  
identify the file in each project that does what I am looking for?

On Sunday, September 21, 2014 4:40:32 PM UTC-4, David Pilato wrote:

> You could give a look at [GitHub - scrutmydocs/scrutmydocs: Search Web Application for hard drive documents](https://github.com/scrutmydocs/scrutmydocs) which  
> basically does that.  
> Or FSRiver: [GitHub - dadoonet/fscrawler: Elasticsearch File System Crawler (FS Crawler)](https://github.com/dadoonet/fsriver)
> 
> Also Elasticsearch unit tests are a good place to find Java code.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 21 sept. 2014 à 22:28, [arke...@gmail.com](mailto:arke...@gmail.com) \<javascript:\> a écrit :
> 
> Very new to elasticsearch, so please be kind.
> 
> Would like to find working code example in Java that:
> 
> (1) creates an index  
> (2) creates a mapping  
> (3) specifies an analyzer  
> (4) converts text files to json  
> (5) loads the json into elasticsearch
> 
> I have successfully created an index using curl and head. I successfully  
> wrote a java program that converts (a directory of) text files to json and  
> loads them into elasticsearch. However the mapping is implied and the  
> analyzer is implied (default?). I would like to programmatically specify  
> the index creation, mapping, and analysis.
> 
> My searches usually result in an example using curl or something  
> off-topic. I suspect what I am trying to do is a very common task, could  
> someone please point me to a working code example ?
> 
> arkerpay
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/03de8921-9f97-4267-952c-f9e4b4ff6a7c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/03de8921-9f97-4267-952c-f9e4b4ff6a7c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 21, 2014, 9:14pm UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901/4 "2014-09-21T21:14:40Z")

</div>

May be this?

[https://github.com/dadoonet/fsriver/blob/master/src/main/java/fr/pilato/elasticsearch/river/fs/river/FsRiver.java#L315](https://github.com/dadoonet/fsriver/blob/master/src/main/java/fr/pilato/elasticsearch/river/fs/river/FsRiver.java#L315)  
[https://github.com/dadoonet/fsriver/blob/master/src/main/java/fr/pilato/elasticsearch/river/fs/river/FsRiver.java#L211](https://github.com/dadoonet/fsriver/blob/master/src/main/java/fr/pilato/elasticsearch/river/fs/river/FsRiver.java#L211)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 sept. 2014 à 22:53, [arkerpay@gmail.com](mailto:arkerpay@gmail.com) a écrit :

Appreciate the quick response! These are large projects. Could you identify the file in each project that does what I am looking for?

> On Sunday, September 21, 2014 4:40:32 PM UTC-4, David Pilato wrote:  
> You could give a look at [GitHub - scrutmydocs/scrutmydocs: Search Web Application for hard drive documents](https://github.com/scrutmydocs/scrutmydocs) which basically does that.  
> Or FSRiver: [GitHub - dadoonet/fscrawler: Elasticsearch File System Crawler (FS Crawler)](https://github.com/dadoonet/fsriver)
> 
> Also Elasticsearch unit tests are a good place to find Java code.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 21 sept. 2014 à 22:28, [arke...@gmail.com](mailto:arke...@gmail.com) a écrit :
> 
> Very new to elasticsearch, so please be kind.
> 
> Would like to find working code example in Java that:
> 
> (1) creates an index  
> (2) creates a mapping  
> (3) specifies an analyzer  
> (4) converts text files to json  
> (5) loads the json into elasticsearch
> 
> I have successfully created an index using curl and head. I successfully wrote a java program that converts (a directory of) text files to json and loads them into elasticsearch. However the mapping is implied and the analyzer is implied (default?). I would like to programmatically specify the index creation, mapping, and analysis.
> 
> My searches usually result in an example using curl or something off-topic. I suspect what I am trying to do is a very common task, could someone please point me to a working code example ?
> 
> ## arkerpay
> 
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9be9cd1-65d6-4309-a753-b7791d0b12bf%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/03de8921-9f97-4267-952c-f9e4b4ff6a7c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/03de8921-9f97-4267-952c-f9e4b4ff6a7c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/57174F36-32FC-4A14-9837-E6972F78B909%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/57174F36-32FC-4A14-9837-E6972F78B909%40pilato.fr).  
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:00am UTC](https://discuss.elastic.co/t/using-java-api-to-map-load-and-index/19901/5 "2017-07-06T01:00:49Z")

</div>


