Integration of elasticsearch with neo4j database

后端 未结 2 1269
执笔经年
执笔经年 2021-01-24 20:15

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

相关标签:
2条回答
  • 2021-01-24 20:59

    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 讨论(0)
  • 2021-01-24 21:17

    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
    ...
    
    0 讨论(0)
提交回复
热议问题