# "Cannot specify a query in the target index and through es.query" when working with ES, Wikipedia River and Hive

**URL:** https://discuss.elastic.co/t/cannot-specify-a-query-in-the-target-index-and-through-es-query-when-working-with-es-wikipedia-river-and-hive/23326
**Category:** Elasticsearch
**Created:** [April 20, 2015, 3:00pm UTC](https://discuss.elastic.co/t/cannot-specify-a-query-in-the-target-index-and-through-es-query-when-working-with-es-wikipedia-river-and-hive/23326 "2015-04-20T15:00:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Gordon](https://avatars.discourse-cdn.com/v4/letter/g/3da27b/32.png) [@Gordon](https://discuss.elastic.co/u/Gordon)
#### Post date: [April 20, 2015, 3:00pm UTC](https://discuss.elastic.co/t/cannot-specify-a-query-in-the-target-index-and-through-es-query-when-working-with-es-wikipedia-river-and-hive/23326/1 "2015-04-20T15:00:07Z")

</div>

Hi,

I've largely got everything setup to integrate ES and Hive. However, when I  
execute a query against the table "wikitable" as defined below, I get the  
error

_Cannot specify a query in the target index and through es.query_

Versions are ES Hive integration, 2.1.0.Beta3; ES, 1.4.4; and, I'm running  
on the latest Hadoop/Hive (installed last week directly from Apache).

I suspect the error has to do with the definition of the resource for the  
external table

wikipedia\_river/page/\_search?q

which I found in this excellent article here

> **[Tableau to ElasticSearch (Querying ElasticSearch with Hive SQL and Hadoop)](http://ryrobes.com/systems/connecting-tableau-to-elasticsearch-read-how-to-query-elasticsearch-with-hive-sql-and-hadoop/)**
>
> A Step-by-Step / How-To Guide for: Tableau -\> Hive SQL -\> Hadoop -\> Map/Reduce -\> ES. With no Full House references in sight!

things may have changed however since the article was written. For  
instance, I had to take the es.host property out of the table definition  
and instead make sure I used es.nodes in a set statement in Hive. Things  
like that usually take a bit of digging and experimenting to figure out.  
I've gotten to where there's an attempt to execute the query and would  
appreciate it if anyone could shed some light on how to work beyond this  
point. Thanks!

## Hive statements

set es.nodes=peace;  
set es.port=9201;

DROP TABLE IF EXISTS wikitable;

CREATE EXTERNAL TABLE wikitable (  
title string,  
redirect\_page string )  
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.resource' = 'wikipedia\_river/page/\_search?q=\*'  
);

select count(distinct title) from wikitable;

* * *

Full stack trace:

* * *

org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot specify a  
query in the target index and through es.query  
at org.elasticsearch.hadoop.rest.Resource.(Resource.java:48)  
at  
org.elasticsearch.hadoop.rest.RestRepository.(RestRepository.java:88)  
at  
org.elasticsearch.hadoop.rest.RestService.findPartitions(RestService.java:226)  
at  
org.elasticsearch.hadoop.mr.EsInputFormat.getSplits(EsInputFormat.java:406)  
at  
org.elasticsearch.hadoop.hive.EsHiveInputFormat.getSplits(EsHiveInputFormat.java:112)  
at  
org.elasticsearch.hadoop.hive.EsHiveInputFormat.getSplits(EsHiveInputFormat.java:51)  
at  
org.apache.hadoop.hive.ql.io.HiveInputFormat.addSplitsForGroup(HiveInputFormat.java:306)  
at  
org.apache.hadoop.hive.ql.io.HiveInputFormat.getSplits(HiveInputFormat.java:408)  
at  
org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getCombineSplits(CombineHiveInputFormat.java:361)  
at  
org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getSplits(CombineHiveInputFormat.java:571)  
at  
org.apache.hadoop.mapreduce.JobSubmitter.writeOldSplits(JobSubmitter.java:624)  
at  
org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:616)  
at  
org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:492)  
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1296)  
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1293)  
at java.security.AccessController.doPrivileged(Native Method)  
at javax.security.auth.Subject.doAs(Subject.java:422)  
at  
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)  
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1293)  
at org.apache.hadoop.mapred.JobClient$1.run(JobClient.java:562)  
at org.apache.hadoop.mapred.JobClient$1.run(JobClient.java:557)  
at java.security.AccessController.doPrivileged(Native Method)  
at javax.security.auth.Subject.doAs(Subject.java:422)  
at  
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)  
at  
org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:557)  
at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:548)  
at  
org.apache.hadoop.hive.ql.exec.mr.ExecDriver.execute(ExecDriver.java:428)  
at  
org.apache.hadoop.hive.ql.exec.mr.MapRedTask.execute(MapRedTask.java:137)  
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)  
at  
org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:88)  
at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1638)  
at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1397)  
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1183)  
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1049)  
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1039)  
at  
org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:207)  
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:159)  
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:370)  
at  
org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:754)  
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)  
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at  
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  
at  
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:497)  
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)  
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)  
Job Submission failed with exception  
'org.elasticsearch.hadoop.EsHadoopIllegalArgumentException(Cannot specify a  
query in the target index and through es.query)'  
FAILED: Execution Error, return code 1 from  
org.apache.hadoop.hive.ql.exec.mr.MapRedTask

Regards,

Gordon

--  
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/ffaa8665-8123-4902-b33a-fb0e28488938%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ffaa8665-8123-4902-b33a-fb0e28488938%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, 12:18am UTC](https://discuss.elastic.co/t/cannot-specify-a-query-in-the-target-index-and-through-es-query-when-working-with-es-wikipedia-river-and-hive/23326/2 "2017-07-06T00:18:40Z")

</div>


