Is there a way to force a couchdb river update?

Looking at the couchdb river code, it looks like it's fairly simple to
expose the river state, simply add a flag to CouchdbRiver.Indexer.run()
loop:

                idle = true;
                logger.info("finished indexing");
                String s;
                try {
                    s = stream.take();
                    logger.info("indexing...");
                    idle = false;

Since the stream is a blocking queue, idle flag in CouchdbRiver
instance would only be true if there are no pending changes in the feed.
The next question is, is there an easy way to expose additional river state
through the existing JSON API? _meta information, perhaps?

thanks in advance,
Andrius

On Tuesday, March 27, 2012 9:53:08 PM UTC+3, kimchy wrote:

There isn't a way to wait till it gets indexed in elasticsearch, I mean,
the river does not expose it. I can't think of a really nice solution
except maybe to do a get for hte doc in elasticsearch (without the _source,
i.e. empty fields), and then poll the doc with another get till the
_version changes...

On Tue, Mar 27, 2012 at 3:39 PM, Andrius Juozapaitis andriusj@gmail.comwrote:

Hey all,

Looking for advice here. I am using couchdb as my data store, with
elasticsearch handling pretty much all the read operations. I've
encountered an issue with the near-real-time indexing through couchdb
river though:

  1. My spring MVC controller extracts data (say, a product list) using
    elasticsearch java api
  2. The user submits a new product
  3. The product is saved in couchdb
  4. The controller, following a redirect-after-post pattern, does an
    http redirect to the product list (see 1.)

The problem here is that the controller in step 1. is querying
elasticsearch data which hasn't been updated yet by the couchdb river.
I am aware there are a number of potential solutions to this problem
(also storing the saved data in session, querying couchdb directly,
delaying the redirect, using ajax, etc).

The most transparent way, IMHO, would be to issue a request to
elasticsearch (or couchdb river?) that would block until the couchdb
river processes all the pending changes in the _changes feed, and only
then perform the http redirect in the step 4. Is it possible to do
through the existing APIs? Are there any other options I missed? In
other words, I'd be happy for any constructive feedback here.

Best regards,
Andrius