private static uint FindDocId(IBaseWindow baseWin, WritableDatabase database, string xref) { uint result; string key = "Q" + GetSign(baseWin) + "_" + xref; using (PostingIterator p = database.PostListBegin(key)) { if (p == database.PostListEnd(key)) { result = 0; // 0 - is invalid docid (see XapianManual) } else { result = p.GetDocId(); } } return(result); }