Do i have to remove from Index if i delete using Cypher? - java

Given i have node or, relation that is added to graph Indexes. When i delete the node / relation, do I also have to remove from Index? We delete within transactions from java API as well us using cypher

If you are using auto indexing then Neo4j will take care of removing it from the index. If you are using manual(or Explicit) indexing then I know there is a cypher way to delete the entire index but not sure if Neo4j supports removing individual entries from the manual index. You can check summarization on different Neo4j indexes here.
Docs on index manipulation with cypher.

Related

Is it possible in Hibernate Search to predefined Query or conditions before the indexing process?

I am using MassIndexer with #Indexed interceptor and it works just fine I am able to filter the entities. but the problem is that I have thousands of soft-deleted records, I don't want these objects to be in the indexing process since they are not important anymore.
so, is it possible in Hibernate Search to predefined query or conditions before the indexing process?
You can't do indexing with predefined HQL. Rather you can intercept the indexing process and instruct indexer whether it should index, skip or remove index for entity.
Please refer to Conditional Indexing topic in Reference Guilde.
Under your conditions: when > 95% of data is not to be indexed I would suggest the following:
Consider manual reindexing by running query and pushing items to index as described in Manual index changes
Consider splitting full data table and only active data table. This is a bit of data duplication but should give you considerable performance gains when working with active records only.

How do I retrieve the nodes deleted after a cypher query?

So I'm deleting some nodes from a database, and I want to retrieve the nodes I've deleted so far so that I don't go looking for them later.
How do I get neo4j ids of the deleted nodes in java code?
You can return the ids of the nodes as you're deleting them:
MATCH (n:SomeLabel)
DELETE n
RETURN id(n)
However, as mentioned in the documentation, ids can be reused by Neo4j, so it's generally a bad idea to keep referencing them outside of a transaction (not sure if that's your use case).

Disable primary key index in MongoDB and enable it after bulk insterting?

Is it possible to disable primary key index in MongoDB and enable it after bulk inserting?
The reason is performance during heavy bulk insert.
I'm using JAVA.
No, you cannot drop _id index. See official documentation:
db.collection.dropIndex(index)
Drops or removes the specified index from a collection. The db.collection.dropIndex() method provides a wrapper around the dropIndexes command.
Note
You cannot drop the default index on the _id field.
Apart from what zero323 has mentioned, it is not always a good idea to disable/enable idexes on the already populated collection even if you are doing bulk inserts.
The reasons that in the beginning you have to remove all the indexes that were previously there, insert the data and then redo indexes for previous data and also for the data which was just added with bulk insert.

Updating lucene index - the most popular way

I am updating lucene index onec a day. My strategy in general is:
Find all objects in DB that was modified since last index generation.
Create new tmp-index for these objects. (old index is stil available)
Remove all new indexed Documents (they are in tmp-index) from the old index using IndexWriter.deleteDocuments(Term)
Merge old index and tmp-index using IndexWriter.addIndexes(...)
I have found that in lucene wiki: There is no direct update procedure in Lucene...
I have found also that in lucene 4.1.0 doc: A document can be updated with updateDocument...
I have tried IndexWriter.updateDocument(Term, Document) but then performing search with filter I got NPE from one of my methods what not happens when I update index as describe in 1-4. Have anyone had a similar problem? How do you update your index?
What I do is basically this:
I keep a persistent IndexReader/Readers, this will keep the state that it has since it was created.
I start to delete and create all documents once again. I think I just do a deleteAll() and then recreate them (addDocument()).
I commit, which will activate all those changes.
I drop all IndexReaders that I have, so the next time the system request a Reader, it will create it and store it for subsequent requests.
The updateDocument is basically a delete/create, afaik.
You might want to use a SearcherManager to get new IndexSearchers as you update the index with a IndexWriter. I see no need for using a temporary index?

How Indexing improve query performance in mongodb

I need to know abt how indexing in mongo improve query performance. And currently my db is not indexed. How can i index an existing DB.? Also is i need to create a new field only for indexing.?.
Fundamentally, indexes in MongoDB are similar to indexes in other database systems. MongoDB supports indexes on any field or sub-field contained in documents within a MongoDB collection.
Indexes are covered in detail here and I highly recommend reading this documentation.
There are sections on indexing operations, strategies and creation options as well as a detailed explanations on the various indexes such as compound indexes (i.e. an index on multiple fields).
One thing to note is that by default, creating an index is a blocking operation. Creating an index is as simple as:
db.collection.ensureIndex( { zip: 1})
Something like this will be returned, indicating the index was correctly inserted:
Inserted 1 record(s) in 7ms
Building an index on a large collection of data, the operation can take a long time to complete. To resolve this issue, the background option can allow you to continue to use your mongod instance during the index build.
Limitations on indexing in MongoDB is covered here.

Categories

Resources