Dear all, Hi, As a part of my code I have to update Lucene document. For this purpose I used writer.updateDocument() method. My problem is the update process is not affect index until restarting Solr. Would you please tell me what part of my code is wrong? Or what should I add in order to apply the changes?
RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core); try { IndexWriter writer = iw.get(); FieldType type= new FieldType(StringField.TYPE_STORED); for (int i = 0; i < hits.length; i++) { Document document = searcher.doc(hits[i].doc); List<String> keywords = keyword.getKeywords(hits[i].doc); if (keywords.size() > 0) document.removeFields(keywordField); for (String word : keywords) { document.add(new Field(keywordField, word, type)); } String uniqueKey = searcher.getSchema().getUniqueKeyField().getName(); writer.updateDocument(new Term(uniqueKey, document.get(uniqueKey)), document); } writer.commit(); } finally { iw.decref(); } Best regards. -- A.Nazemian