Skip to content

Commit

Permalink
catch allready existing indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim authored and Tim committed Aug 5, 2020
1 parent 8b90389 commit 6afb9d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os
from py2neo import Graph
from py2neo.database import ClientError
queries = {}

queries["textOfPapersAndPatents"] = 'CALL db.index.fulltext.createNodeIndex("textOfPapersAndPatents",["Fragment", "Abstract", "Paper", "Patent", "PatentTitle", "PatentClaim","PatentAbstract"],["title", "text"])'
queries["GeneSymbolFullTextIndex"] = 'CALL db.index.fulltext.createNodeIndex("GeneSymbolFullTextIndex",["GeneSymbol"],["sid"])'
queries["AuthorFullTextIndex"] = 'CALL db.index.fulltext.createNodeIndex("AuthorFullTextIndex",["Author"],["first", "middle","last"])'
queries["EntityFullTextIndex"] = 'CALL db.index.fulltext.createNodeIndex("EntityFullTextIndex",["Entity"],["name"])'
g = Graph(host=os.getenv("GC_NEO4J_URL", None), user=os.getenv(
g = Graph(os.getenv("GC_NEO4J_URL", None), user=os.getenv(
"GC_NEO4J_USER", None), password=os.getenv("GC_NEO4J_PASSWORD", None))

for name, query in queries.items():
print("Create fulltext index '{}'".format(name))
g.run(query)
try:
g.run(query)
except ClientError as e:
print("Index '{}' allready exists. Skip.".format(name))

0 comments on commit 6afb9d9

Please sign in to comment.