My use-case is to insert a new document and immediately after run a N1QL query which should include the newly inserted document. This is how I insert the document:
WebAppServletContextListener.collection.insert(docName, doc);
runN1qlQuery();
The newly inserted doc is not included in the result set. But it will if I run have this code:
WebAppServletContextListener.collection.insert(docName, doc);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
runN1qlQuery();
I think this is because the document takes time to get indexed. Is there a way to find out when this is the case, i.e. with a callback? Something like this:
WebAppServletContextListener.collection.insert(docName, doc, new IndexListener("specified-index-A", "specified-index-B") {
@Override
public void onIndexed() {
runN1qlQuery();
}
});
I’m also open to other solutions to solve the use-case appropriately!