# Querying elastic search DB using the index name - failing

**URL:** <https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799>\
**Category:** Logstash\
**Created:** [February 14, 2018, 1:04pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799 "2018-02-14T13:04:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranganath\_nangineni](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ranganath\_nangineni](https://discuss.elastic.co/u/ranganath_nangineni)\
**Post date:** [February 14, 2018, 1:04pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799/1 "2018-02-14T13:04:59Z")

</div>

Hi

I have multiple indexes in my elastic search DB. I am trying to query one of the index among them but the query is failing and it is connecting to a differnt index rather than the one that i mentioned in the query.

The script is as below:

if [docname] {  
elasticsearch {  
hosts =\> ["[XYZ.com:9200/test-myo-docs/data](http://XYZ.com:9200/test-myo-docs/data)"]  
query =\> 'ddocname:%{docname}'  
fields =\> ["ddoctitle"]  
#We can any number of fields

```
                   sort => "ddoctitle:desc"
    }

```

The log output:

":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"kA0NmuwhSS2d9rf\_gpozFQ","index":" **token-prod-na-ucf-wls-2018.02.05**"}},{"shard":0,"index":"token-prod-na-ucf-wls-2018.02.06","node":"hdokW\_3gQFeowO0oKgOOrQ","reason":{"type":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"OlkNtnNMTTmQk3xU9Tp-qw","index":"token-prod-na-ucf-wls-2018.02.06"}},{"shard":0,"index":"token-prod-na-ucf-wls-2018.02.07","node":"hdokW\_3gQFeowO0oKgOOrQ","reason":{"type":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"2pWHJ5HRRLWFiDkMuKQg3w","index":"token-prod-na-ucf-wls-2018.02.07"}},{"shard":0,"index":"token-prod-na-ucf-wls-2018.02.08","node":"ubu7iS9YQ3aUHB-\_KWUqpw","reason":{"type":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"JPf9oL4fSh-OwMzRMlxodA","index":"token-prod-na-ucf-wls-2018.02.08"}},{"shard":0,"index":"token-prod-na-ucf-wls-2018.02.09","node":"hdokW\_3gQFeowO0oKgOOrQ","reason":{"type":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"Keq5vxzyQWuyaVtm0t9kQQ","index":"token-prod-na-ucf-wls-2018.02.09"}},{"shard":0,"index":"token-prod-na-ucf-wls-2018.02.10","node":"hdokW\_3gQFeowO0oKgOOrQ","reason":{"type":"query\_shard\_exception","reason":"No mapping found for [ddoctitle] in order to sort on","index\_uuid":"0IaimkzuQGanvMsyXhIbIg","index":"token-prod-na-ucf-wls-2018.02.10"}}]},"status":400}\>}

What is the reason behind this ? and how can I force the query to use the correct index?

---

<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:** [February 14, 2018, 1:27pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799/2 "2018-02-14T13:27:15Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Please edit your post.

Is it a logstash "Script"? What is that?

---

<div class="post-metadata">

**Author:** ![ranganath\_nangineni](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ranganath\_nangineni](https://discuss.elastic.co/u/ranganath_nangineni)\
**Post date:** [February 14, 2018, 2:41pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799/3 "2018-02-14T14:41:31Z")

</div>

Yes. It is logstash script.

How can I write an exception for the no mapping.

Logstash log:  
type"=\>"query\_shard\_exception", "reason"=\>"No mapping found for [@timestamp] in order to sort on"

---

<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:** [February 14, 2018, 3:22pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799/4 "2018-02-14T15:22:13Z")

</div>

Is it the same question? You mentioned first something about `ddoctitle`.

I moved your question to #logstash

---

<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:** [March 14, 2018, 3:22pm UTC](https://discuss.elastic.co/t/querying-elastic-search-db-using-the-index-name-failing/119799/5 "2018-03-14T15:22:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
