# Elasticsearch filter plugin query failure

**URL:** <https://discuss.elastic.co/t/elasticsearch-filter-plugin-query-failure/48838>\
**Category:** Logstash\
**Created:** [April 29, 2016, 8:16pm UTC](https://discuss.elastic.co/t/elasticsearch-filter-plugin-query-failure/48838 "2016-04-29T20:16:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchoinski](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jchoinski](https://discuss.elastic.co/u/jchoinski)\
**Post date:** [April 29, 2016, 8:16pm UTC](https://discuss.elastic.co/t/elasticsearch-filter-plugin-query-failure/48838/1 "2016-04-29T20:16:02Z")

</div>

Hello,

I'm trying to query for an instrument in elasticsearch and calculate the time difference between the events. I'm running into an error trying to query elasticsearch.

Here is the config.

filter {  
if [type] == "kafka-instrument" {  
elasticsearch {  
hosts =\> ["127.0.0.1"]  
query =\> 'type:def AND \_id:%{[key][dvi]}'  
fields =\> ["@timestamp"]  
}

```
}

```

}

and here is the error.  
{:timestamp=\>"2016-04-29T15:09:56.616000-0500", :message=\>"Failed to query elasticsearch for previous event", :query=\>"type:def AND \_id:176", :event=\>#\<LogStash::Event:0x33dfaf04 @metadata\_accessors=#\<LogStash::Util::Accessors:0x2be39827 @store={}, @lut={}\>, @cancelled=false, @data={REMOVEDFORBREVITY}\>\>, :error=\> #\<NoMethodError: undefined method `[]' for nil:NilClass\>, :level=\>:warn}

Any ideas?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 1, 2016, 1:38am UTC](https://discuss.elastic.co/t/elasticsearch-filter-plugin-query-failure/48838/2 "2016-05-01T01:38:16Z")

</div>

Check your ES logs as well, there should be something related.

---

<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, 4:59am UTC](https://discuss.elastic.co/t/elasticsearch-filter-plugin-query-failure/48838/3 "2017-07-06T04:59:49Z")

</div>


