1

We are using Lucene to index objects from a RabbitMQ queue, in the event that there are multiple versions of the same object in RabbitMQ we will only ever have one document for it as we use updatedocument(which will find and delete existing records based on a search term and create a new one).

What i would like to do is have a way of ensuring the index is of the most recent object, so if for instance we have 2 updates of an object to RabbitMQ and they are pulled from RabbitMQ out of order, if i have the field 'Version' with the values 1 and 2, is there a way to tell Lucene "dont update document if this document version is lower than the existing document"?

Thanks

Adamon
  • 484
  • 9
  • 21

1 Answers1

0

In the event anyone else has a similar problem, ended up searching the index before updating. It's not the most efficient method but it gets the job done:

var doc = (from d in results
                       let ver = long.Parse(d.GetField("Version").StringValue)
                       where ver < model._Version
                       orderby ver descending
                       select d).FirstOrDefault();

and then we update using the resulting doc.

Adamon
  • 484
  • 9
  • 21