Search code examples
pythonjsonneo4jneo4j-apoc

NEO4J APOC LOAD JSON FROM EXTERNAL VARIABLE


I'm trying to load a json document into Neo4j but, if possible, I don't want to use a file because, in my case, it's a waste of time.

WHAT I'M DOING NOW:

  1. Python query to Elasticsearch Database
  2. Push data into a .json file
  3. From Neo4j Python Library, run apoc.load.json('file:///file.json')

WHAT I WANT TO DO:

  1. Python query to Elasticsearch Database
  2. From Neo4j Python Library, run apoc.load.json()

Is there any syntax that could help me with that? Thank you


Solution

  • If you already have APOC installed, you can utilize the APOC to ES connector without having to use apoc.load.json.

    Here is an example from the documentation:

    CALL apoc.es.query("localhost","bank","_doc",null,{
      query: { match_all: {} },
      sort: [
        { account_number: "asc" }
      ]
    })
    YIELD value
    UNWIND value.hits.hits AS hit
    RETURN hit;
    

    Link to docs: https://neo4j.com/labs/apoc/4.1/overview/apoc.es/