atlas-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "uygar yuzsuren (JIRA)" <>
Subject [jira] [Commented] (ATLAS-446) IndexWriter.updateDocument on FSDirectory does not work Ver.5.4.0
Date Tue, 19 Jan 2016 19:14:39 GMT


uygar yuzsuren commented on ATLAS-446:

I try to create a simple index and then update documents (with IndexWriter.updateDocuments).
When I use RAMDirectory it works fine (IndexWriter.numDocs returns correct value,
returns correct hits). However, when I use FSDirectory it creates duplicate documents, and
IndexSearcher returns multiple documents with same key field values. Here is the code excerpt:

//This code is in a thread and it updates documents with regular intervals, say 1 min.

Analyzer analyzer = new StandardAnalyzer();

		    try {
				Path path =  Paths.get(indexDirectory);
				Directory directory =;
				IndexWriterConfig config = new IndexWriterConfig(analyzer);
				IndexWriter iwriter = new IndexWriter(directory, config);
				System.out.println("Document count=" + iwriter.numDocs());
				for (Company newCompany : newCompanies) {
					Document doc = new Document();
				    doc.add(new Field("entityid", "Company" + newCompany.getId().toString(), TextField.TYPE_STORED));
				    doc.add(new Field("companyname", newCompany.getName(), TextField.TYPE_NOT_STORED));
				    Term term = new Term("entityid", "Company" + newCompany.getId().toString());				 
				    iwriter.updateDocument(term, doc);			     

				System.out.println("Document count2=" + iwriter.numDocs());
			} catch (IOException e1) {

> IndexWriter.updateDocument on FSDirectory does not work Ver.5.4.0
> -----------------------------------------------------------------
>                 Key: ATLAS-446
>                 URL:
>             Project: Atlas
>          Issue Type: Bug
>            Reporter: uygar yuzsuren

This message was sent by Atlassian JIRA

View raw message