3
votes

Currently, we are building our neo4j project using neo4j-jdbc drivers. We are performing all the operations like creating nodes with properties, deleting nodes and creating relations between two nodes using cypher queries. The sample code is like this

Class.forName("org.neo4j.jdbc.Driver");

// Connect
 Connection con = DriverManager.getConnection("jdbc:neo4j://localhost:7474/");

// Querying
try(Statement stmt = con.createStatement())
{
  ResultSet rs = stmt.executeQuery("MATCH (n:User) RETURN n.name");
  while(rs.next())
  {
    System.out.println(rs.getString("n.name"));
  }
}

We are performing all the basic searching using cypher queries clauses. I have studied about the indexing in neo4j tried to understand that too but still not succeeded in understanding whats full-text indexing exactly means.

Now we have to apply full text searching in our project but we are not getting any idea of how to use Lucene Queries with Cypher Queries to apply for full-text search. The sample code we got of use of Lucene query in neo4j was by using an embedded database or rest API.

PROBLEM:-

  1. Full-text search in neo4j.

  2. Embed lucene queries in cypher queries.

  3. Full-text Indexing.

1
I have read this question.Its not helpful to me.user3359536

1 Answers

4
votes

There are some basic string comparison operators available in Cypher, including STARTS WITH, ENDS WITH, and CONTAINS.

For example:

MATCH (n.User) WHERE n.name STARTS WITH "Bob" RETURN n;

For more powerful full text indexing you will need to use what Neo4j refers to as Legacy Indexes. See this blog post for an overview.

Once you have enabled the legacy auto index you can reference it in a START clause in Cypher passing any lucene query. For example:

START user=node:node_auto_index("name:Bob*")
...