이 문제는 이전에 아무런 문제가 없었고 일반적인 수정이 적용되지 않는 것을 제외하면 일반적인 문제입니다. 아마 어리석은 일이지만, 나는 그것을 찾을 수 없다.Lucene updateDocument가 문서를 삭제하지 않습니다.
yammer api가 내 목적에 충분히 빠르지 만 yammer 사이트를 색인하려고합니다. 문제는 updateDocument 기능을 사용하여 색인을 업데이트하려고 할 때 이전 색인이 삭제되지 않습니다. 그러나 분석되지 않은 저장된 고유 키가 있습니다. 내 로그에 표시되는 내용
Document newdoc = new Document();
newdoc.add(new Field(YammerMessageFields.URL, resultUrl, Field.Store.YES, Field.Index.NOT_ANALYZED));
newdoc.add(new Field(YammerMessageFields.THREAD_ID, threadID.toString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
newdoc.add(new Field(YammerMessageFields.AUTHOR, senderName, Field.Store.YES, Field.Index.ANALYZED));
newdoc.add(new Field(YammerMessageFields.CONTENTS, resultText, Field.Store.YES, Field.Index.ANALYZED));
Term key = new Term(YammerMessageFields.THREAD_ID, newdoc.getFieldable(YammerMessageFields.THREAD_ID).toString());
logger.debug("updating document with key: " + key);
try {
IndexWriter writer = getIndexWriter();
writer.updateDocument(key, newdoc);
writer.close();
} catch (IOException e) {
}
은 다음과 같습니다 : 여기
는 관련 코드 이2012-05-11 12:02:29,816 DEBUG [http-8088-2] LuceneIndex - https://www.yammer.com/api/v1/messages/?newer_than=0
2012-05-11 12:02:38,594 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173285202>
2012-05-11 12:02:45,167 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173033239>
2012-05-11 12:02:51,686 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173014568>
2012-05-11 12:02:51,871 DEBUG [http-8088-2] LuceneIndex - new items:3
2012-05-11 12:03:27,393 DEBUG [http-8088-2] YammerResource - return all documents
2012-05-11 12:03:27,405 DEBUG [http-8088-2] YammerResource - nr docs:3
2012-05-11 12:03:27,405 DEBUG [http-8088-2] YammerResource - nr dels:0
...
next update
...
2012-05-11 12:03:35,802 DEBUG [http-8088-2] LuceneIndex - https://www.yammer.com/api/v1/messages/?newer_than=0
2012-05-11 12:03:43,933 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173322760>
2012-05-11 12:03:50,467 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173285202>
2012-05-11 12:03:56,982 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173056406>
2012-05-11 12:04:03,533 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173033239>
2012-05-11 12:04:10,097 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173030769>
2012-05-11 12:04:16,629 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173014568>
2012-05-11 12:04:23,169 DEBUG [http-8088-2] LuceneIndex - updating document with key: threadid:stored,indexed<threadid:173003570>
2012-05-11 12:04:23,341 DEBUG [http-8088-2] LuceneIndex - new items:7
2012-05-11 12:05:09,694 DEBUG [http-8088-1] YammerResource - return all documents
2012-05-11 12:05:09,696 DEBUG [http-8088-1] YammerResource - nr docs:10
2012-05-11 12:05:09,696 DEBUG [http-8088-1] YammerResource - nr dels:0
그래서 키가 다시 발생 (4 새),하지만이 작업을 수행하는 경우가 있습니다 내 저장소에 7 개가 아닌 10 개 문서가 삭제되었습니다 (삭제 된 문서는 3 개).
편집 : 다음은 항목을 찾는 방법입니다. 그러나 실제로 표시하고 루크와 함께 검사했습니다.
IndexReader r = IndexReader.open(searchIndex.getIndex());
List<Document> docList = new ArrayList<Document>();
List<Document> delList = new ArrayList<Document>();
int num = r.numDocs();
num += r.numDeletedDocs();
for (int i = 0; i < num && i < max; i++)
{
if (! r.isDeleted(i))
docList.add(r.document(i));
else
delList.add(r.document(i));
}
r.close();
logger.debug("nr docs:" + docList.size());
logger.debug("nr dels:" + delList.size());
lucene 사용 3.4.0 btw – Rhand
그리고 doc 카운트를 찾기 위해 어떤 API 호출이 사용됩니까? –
수 있습니다. 'maxDoc'를 호출하면 삭제 된 문서를 고려하지 않는 것으로 알려져 있습니다. 물론 Lucene API 호출에 대해 말하고 있습니다. 그것 이상의 아무것도. –