neo4j-apoc-procedures: apoc.index.* doesn't add or find newly-added nodes in index

Hi all,

I’m trying to use fulltext indexes from APOC, but I’m not having much luck.

I’m running neo4j 3.1.2 and apoc-3.1.2.5 on debian 8.7.

Creating the index on an existing db works as expected:

neo4j-sh (?)$ call apoc.index.addAllNodes( 'search_index', { City: ["name"] } );
+-------------------------------+
| label  | property | nodeCount |
+-------------------------------+
| "City" | "name"   | 1122      |
+-------------------------------+
1 row
866 ms
neo4j-sh (?)$ call apoc.index.search( 'search_index', 'City.name:"La Paz"' ) yield node return node;
+--------------------------------------------------------------------------------------------------------------+
| node                                                                                                         |
+--------------------------------------------------------------------------------------------------------------+
| Node[1593267]{name:"La Paz",url:"/places/bolivia/la-paz",lat:-16.489689,lon:-68.1192936} |
+--------------------------------------------------------------------------------------------------------------+

But although I have “autoUpdate” set in neo4j.conf:

$ fgrep autoUpdate /etc/neo4j/neo4j.conf
apoc.autoUpdate.enabled=true

Adding new items doesn’t automatically update the index (I’ve tried restarting the server after creating the index, but it doesn’t make any difference):

neo4j-sh (?)$ create (c:City{name:"Made Up City",url:"/places/nowhere/made-up-city"}) return c;
+-----------------------------------------------------------------------+
| c                                                                     |
+-----------------------------------------------------------------------+
| Node[1746889]{url:"/places/nowhere/made-up-city",name:"Made Up City"} |
+-----------------------------------------------------------------------+
1 row
Nodes created: 1
Properties set: 2
Labels added: 1
77 ms
neo4j-sh (?)$ call apoc.index.search( 'search_index', 'City.name:"Made Up"' ) yield node return node;
+------+
| node |
+------+
+------+
0 row
134 ms
neo4j-sh (?)$ start n=node:search_index('name:"Made Up"') return n;
+---+
| n |
+---+
+---+
0 row
46 ms

So I try to add the node to the index manually, but whether I have autoUpdate set to true or not, adding the node directly with addNode doesn’t work:

neo4j-sh (?)$ match (c:City{url:"/places/nowhere/made-up-city"}) with c call apoc.index.addNode( c, [ 'name' ] ) return c;
+-----------------------------------------------------------------------+
| c                                                                     |
+-----------------------------------------------------------------------+
| Node[1746893]{name:"Made Up City",url:"/places/nowhere/made-up-city"} |
+-----------------------------------------------------------------------+
1 row
86 ms
neo4j-sh (?)$ call apoc.index.search( 'search_index', 'City.name:"Made Up"' ) yield node return node;
+------+
| node |
+------+
+------+
0 row
11 ms
neo4j-sh (?)$ start n=node:search_index('name:"Made Up"') return n;
+---+
| n |
+---+
+---+
0 row
8 ms

Adding with addNodeByLabel doesn’t work either:

neo4j-sh (?)$ match (c:City{url:"/places/nowhere/made-up-city"}) with c call apoc.index.addNodeByLabel( 'City', c, [ 'name' ] ) return c;
+-----------------------------------------------------------------------+
| c                                                                     |
+-----------------------------------------------------------------------+
| Node[1746893]{name:"Made Up City",url:"/places/nowhere/made-up-city"} |
+-----------------------------------------------------------------------+
1 row
77 ms
neo4j-sh (?)$ call apoc.index.search( 'search_index', 'City.name:"Made Up"' ) yield node return node;
+------+
| node |
+------+
+------+
0 row
11 ms
neo4j-sh (?)$ start n=node:search_index('name:"Made Up"') return n;
+---+
| n |
+---+
+---+
0 row
11 ms

Adding the node with addNodeByName does add the node to the index:

neo4j-sh (?)$ match (c:City{url:"/places/nowhere/made-up-city"}) with c call apoc.index.addNodeByName( 'search_index',  c, [ 'name' ] ) return c;
+-----------------------------------------------------------------------+
| c                                                                     |
+-----------------------------------------------------------------------+
| Node[1746893]{name:"Made Up City",url:"/places/nowhere/made-up-city"} |
+-----------------------------------------------------------------------+
1 row
55 ms
neo4j-sh (?)$ start n=node:search_index('name:"Made Up"') return n;
+-----------------------------------------------------------------------+
| n                                                                     |
+-----------------------------------------------------------------------+
| Node[1746893]{name:"Made Up City",url:"/places/nowhere/made-up-city"} |
+-----------------------------------------------------------------------+
1 row
19 ms

But even then, apoc.index.search doesn’t find the node:

neo4j-sh (?)$ call apoc.index.search( 'search_index', 'City.name:"Made Up"' ) yield node return node;
+------+
| node |
+------+
+------+
0 row
6 ms

Would be great to know if I’m doing something wrong, or if there’s something else going on?

Thanks! Igor

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 39 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I haven’t checked for a while as I’ve been working on other projects. I’d really like to be able to use this though as it would enable some significant feature improvements for my Neo4J project. @sarmbruster I’m sure you’ve had a lot on your plate too - do you know the current situation with this?

Thanks 👍

@jaredhancock31 your issue is not related. Based on a private conversation I’ve identified yours as an duplicate of #778. Not the symptom but the root cause: use of URL.setStreamFactoryHandler

I’ve pushed a change today forcing the background thread to explicitly wait until db is available. Additionally a fix for index deletions has been merged, see https://github.com/neo4j/neo4j/pull/11133 After next neo4j release (3.2.x or 3.3.x) we should test this again.