Display Name
Display Name

Reputation: 139

Neo4j indexing doesn't work

I'm using batch insertion method for creation of neo4j graph db. Loading DBpedia data set and constructing the property graph of it.

public Neo4jBatchHandler(BatchInserter db2, int indexCache, int timeout) {
    this.db = db2;
    this.indexCache = indexCache;
    this.timeout = timeout;

    BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(
            db);
    index = indexProvider.nodeIndex("ttlIndex",
            MapUtil.stringMap("type", "exact"));
    index.setCacheCapacity("__URI__", indexCache + 1);

}

this the code which I am using for indexing.


During Query operations I want to use Indexing possibility for efficiency. But unfortunately it doesn't work. Here is the my code:

    IndexHits<Long> hits = index.get("__URI__",
                    resourceName);

it returns null, but I'm sure that db contains the resource with the resourceName. How should I use indexes here, for query?

Upvotes: 0

Views: 64

Answers (1)

Luanne
Luanne

Reputation: 19373

Did you actually add the nodes to the index? For example:

index.add(node,properties)

Are you querying during the batch insertion process? If so, flush the index

index.flush();

so that the newly indexed nodes are visible for querying. It is recommended that you do not do this frequently, see http://neo4j.com/docs/stable/indexing-batchinsert.html

Upvotes: 1

Related Questions