I am indexing a row of data from database in Lucene.Net. A row is equivalent of Document.
I want to update my database with the DocId, so that I can use the DocId in the results to be able to retrieve rows quickly.
I currently first retrive the PK from the result docs which I think should be slower than retriving directly from the database using DocId.
How can I find the DocId when adding a document to Lucene?
As Yuval stated, leaking internal Lucene implementation details is bad, especially since Lucene doc id’s change when the index is mutated.
If looking up the primary key using doc.get(“pk”) is too slow for you, use a FieldCache to cache all the pk’s in memory. Then the lookups will be plenty fast.