Integration of elasticsearch with neo4j database

蓝咒 提交于 2019-12-02 08:41:44

问题


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


回答1:


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



回答2:


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
...


来源:https://stackoverflow.com/questions/48518360/integration-of-elasticsearch-with-neo4j-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!