Search code examples
neo4jclient

FullText Search / IndexLookup using Neo4jClient


I am trying to execute the following Cypher statement

"START b=node:customer_full_text_idx('ID:"ASHLAND"') return b

I am using this method

var results = _graphClient.QueryIndex<Customer>(Base.INDEX_CUSTOMER_FULL_TEXT, IndexFor.Node, "ID:" + "ASHLAND");

This method throws Lucene exceptions sometimes. This issue is documented at https://bitbucket.org/Readify/neo4jclient/issue/54/spaces-in-search-text-while-searching-for. The QueryIndex is deprecated and I tried recommended Syntax

I tried using recommend Cypher

var results = _graphClient
              .Cypher
              .Start(new { n = Node.ByIndexLookup(Base.INDEX_CUSTOMER_FULL_TEXT, "ID", "ASHLAND") })
              .Return<Customer>("n")
              .Results;

But above statement does not return any results. I think the problem is that above syntax is not designed for FullText and it inserts '=' in the Cypher start. Whereas it expects a ":" between ID and Name. Or may be I am missing something obvious.

Please share any examples using Neo4jClient using the .Start Query. TIA.


Solution

  • Use Node.ByIndexQuery instead of Node.ByIndexLookup.

    (You were using a query before, then swapped to a lookup in the new syntax.)

    This is a lookup: http://docs.neo4j.org/chunked/snapshot/query-start.html#start-node-by-index-lookup

    This is a query: http://docs.neo4j.org/chunked/snapshot/query-start.html#start-node-by-index-query