# Trouble Integrating Elasticsearch into Neo4j

**URL:** <https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109>\
**Category:** Ecosystem & Integrations\
**Tags:** apoc\
**Created:** [September 29, 2021, 12:42pm UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109 "2021-09-29T12:42:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![enjaneerem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/enjaneerem/32/20280_2.png) [@enjaneerem](https://community.neo4j.com/u/enjaneerem)\
**Post date:** [September 29, 2021, 12:42pm UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109/1 "2021-09-29T12:42:15Z")

</div>

I'm having a hard time getting the syntax right on an `apoc.es.query` or an `apoc.es.get` for a nested field call into elasticsearch from my Neo4j database.

I'm running Neo4j 4.3.1 with ELK at 7.15.0.

I am trying to grab specific event IDs such as 4624 for user logons. Which is in `event.code: 4624` and/or `winlog.event_id: 4624` .

Here is what works:

```auto
CALL apoc.es.query("http://user:password@ipaddress:9200","logstash*","_doc","_source",{
  query: { match_all: {} }
})
YIELD value
UNWIND value.hits.hits AS hit
RETURN hit;

```

Here is what doesn't:

```auto
CALL apoc.es.query("http://user:password@ipaddress:9200","logstash*","_doc",null,
{ query: { match: { event.code: 4624}}})
YIELD value
UNWIND value.hits.hits AS hit
RETURN hit;

```

Or same thing with winlog:

```auto
CALL apoc.es.query("http://user:password@ipaddress:9200","logstash*","_doc",null,
{ query: { match: { winlog.event_id: 4624}}})
YIELD value
UNWIND value.hits.hits AS hit
RETURN hit;

```

No matter how I structure it, I either get a syntax error or zero results. What am I missing?

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 30, 2021, 11:48am UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109/2 "2021-09-30T11:48:21Z")

</div>

Hmm, what syntax error are you getting?  
And does the same query work directly against ES?

---

<div class="post-metadata">

**Author:** ![conker84](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/conker84/32/275_2.png) [@conker84](https://community.neo4j.com/u/conker84)\
**Post date:** [September 30, 2021, 12:29pm UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109/3 "2021-09-30T12:29:02Z")

</div>

Plese try with:

```auto
CALL apoc.es.query("http://user:password@ipaddress:9200","logstash*","_doc",null,
{ query: { match: { `winlog.event_id`: 4624}}})
YIELD value
UNWIND value.hits.hits AS hit
RETURN hit;

```

If it doesn't work can you share a sample of your data and the error returned by the procedure?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![enjaneerem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/enjaneerem/32/20280_2.png) [@enjaneerem](https://community.neo4j.com/u/enjaneerem)\
**Post date:** [September 30, 2021, 1:28pm UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109/4 "2021-09-30T13:28:14Z")

</div>

Thanks conker84! That syntax worked!

---

<div class="post-metadata">

**Author:** ![conker84](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/conker84/32/275_2.png) [@conker84](https://community.neo4j.com/u/conker84)\
**Post date:** [September 30, 2021, 2:35pm UTC](https://community.neo4j.com/t/trouble-integrating-elasticsearch-into-neo4j/45109/5 "2021-09-30T14:35:10Z")

</div>

@enjaneerem can you please mark the answer as the correct solution? Thank you!
