I am trying to build a blind search, given an expression/string.
Using Python Neo4j driver I am running:
from neo4j import GraphDatabase
driver = GraphDatabase.driver("neo4j://localhost:7687")
def query_engine(tx, query):
res = tx.run(query)
values = [record for record in res]
return values
def fuzzy_search(tx, search_expression):
query = f"MATCH (n) WHERE ANY(x in keys(n) WHERE n[x] =~ '(i?){search_expression}.*') RETURN n"
res = query_engine(tx, query)
return res
with driver.session() as session:
result = session.read_transaction(fuzzy_search, "kuku.*")
driver.close()
I know I need to add full text index to make it faster, please advise what is the best practice to define the full text index in Neo4j when I want to perform full graph search on the nodes/relations params? For example, I am searching for 'kuku' in my graph across all nodes and relations and if there are any nodes/relations that contain kuku, I would like to be able to return it as a result.
Additional info:I have added to all my nodes an additional label (FTIndex) and I am able to create a full text index, BUT(!), how can I config it to index ALL nodes available params + to be sure it will be updated if I will add new ones?
> @rouven_bauer cold mention? I am just trying to find an answer...
Derived from cold calling: contacting someone proactively without them being engaged in the conversation before.
As for the rest, I'm afraid I'm still not the right person to answer. It seems like it might not be possible https://stackoverflow.com/questions/36560014/neo4j-create-index-for-nodes-with-same-property (not exactly what you asked for, but suggests that you need a common label at least). Neither could I find a way to create an index for "all properties". But don't quote me on that. Again, I'm not a Cypher expert.
@rouven_bauer cold mention? I am just trying to find an answer...
I am aware of all the links and knowledge you've shared, I am way after this research..I know about fulltext search index, this is not the question. Given a graph and I want to search across all nodes and relations on their parameters the string "kuku" I want it to run fast on a large graph.
I can create such index for every group of nodes/relations with the same set of params but then I will need some controller to decide which index to use.
When I create such index, it has a name, and in order to use it, I need to call a specific index, how do I know which one of N I have created is the right one?
My question is deeper than it maybe seems at the first sight. Please advise.