1
votes

Am trying to use elasticsearch with my neo4j database for fast querying.I tried many sites but they are all old articles so i didn't get any clear idea. Steps I followed until now,

  1. Installed neo4j
  2. Installed elasticsearch
  3. Copy pasted elastic search plugins into neo4j plugins folder
  4. added this line into neo4j. properties file

    elasticsearch.host_name=http://localhost:9200
    

    elasticsearch.index_spec=people:Person(first_name,last_name), places:Place(name)

    Here my question is,

  5. How elasticsearch and neo4j are integrated. Please clarify me on this.

I followed this ,

Link

2

2 Answers

1
votes

You have to install Apoc procedures plugin (https://github.com/neo4j-contrib/neo4j-apoc-procedures). The documentation about ES integration is here : ES Integration with Apoc procedures

[edit]

  • download and drop apoc.jar in plugins's Neo4j directory, regarding the targetted Neo4j version

  • restart Neo4j

  • in Neo4j Web browser, launch the following Cypher query to show all ES procedures:

    CALL apoc.help("apoc.es")

Sample query for logs:

CALL apoc.es.getRaw("localhost","_search?q=level:ERROR",null) 
YIELD value 
UNWIND value.hits.hits as hits
RETURN hits LIMIT 100

The recommanded way is to store the ES host in neo4j.conf by adding a key (after restart of Neo4j):

apoc.es.myKey.url=localhost

Then the query looks like:

CALL apoc.es.getRaw("myKey","_search?q=level:ERROR",null) 
YIELD value 
UNWIND value.hits.hits as hits
RETURN hits LIMIT 100
0
votes

For those of you who already have APOC plugin installed and accessible, but don't have access to the neo4j.properties file (or are more comfortable working with ES through curl) you can do this without using apoc.es.getRaw and can instead use the JSON returned with apoc.load.json:

WITH "http://myelasticurl:9200/my_index/_search?q=level:ERROR" as search_url
CALL apoc.load.json(search_url) YIELD value
UNWIND value.hits.hits as hit
WITH hit._source as source
...
# do work
...