# Querying to Elasticsearch from Hadoop

**URL:** <https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [January 7, 2016, 5:40am UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572 "2016-01-07T05:40:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanjay\_Bhosale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Sanjay\_Bhosale](https://discuss.elastic.co/u/Sanjay_Bhosale)\
**Post date:** [January 7, 2016, 5:40am UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572/1 "2016-01-07T05:40:25Z")

</div>

Hi,

I am able to query Elasticsearch DB from main function of Hadoop MapReduce program.  
But when i perform same operation in MapReduce part it shows below error to me.

```
  16/01/07 02:00:35 INFO mapred.JobClient: Task Id : attempt_201601011215_30671_m_000000_2, Status : FAILED
Error: java.lang.ClassNotFoundException: org.elasticsearch.index.query.QueryBuilder
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:270)
        at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:810)
        at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:855)
        at org.apache.hadoop.mapreduce.JobContext.getMapperClass(JobContext.java:199)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:718)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
        at org.apache.hadoop.mapred.Child.main(Child.java:249)

```

What is the cause of this error. Should i need to copy all required jars to some other location?  
Please let me know if have any solution for it.

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [January 9, 2016, 1:40pm UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572/2 "2016-01-09T13:40:54Z")

</div>

You seem to be using Elasticsearch itself in your map reduce job and not ES-Hadoop connector. In that case, just like with any other library out there, you need to deploy ES alongside your map/reduce jobs. The Hadoop documentation provides more information on what are the way to do that.

---

<div class="post-metadata">

**Author:** ![Sanjay\_Bhosale](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Sanjay\_Bhosale](https://discuss.elastic.co/u/Sanjay_Bhosale)\
**Post date:** [January 12, 2016, 9:28am UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572/3 "2016-01-12T09:28:34Z")

</div>

Ok Thanks. I am done with it. Can you please suggest me with the method for just checking if part of field value exists or not. I am able to get no of occurrences but i just want to check if it exists since finding number of occurrences is taking much time.

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [January 12, 2016, 3:35pm UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572/4 "2016-01-12T15:35:44Z")

</div>

I'm not what you are trying to achieve but if you're looking into finding documents that are missing fields or have them declare, take a look at [missing](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-missing-query.html) and [exists](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-exists-query.html) query.

---

<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:26pm UTC](https://discuss.elastic.co/t/querying-to-elasticsearch-from-hadoop/38572/6 "2017-07-06T13:26:26Z")

</div>


