Updating a documenting looses its fields that only indexed, also NumericField
tries are completely lost
-------------------------------------------------------------------------------------------------------
Key: LUCENE-2863
URL: https://issues.apache.org/jira/browse/LUCENE-2863
Project: Lucene - Java
Issue Type: Bug
Components: Store
Affects Versions: 3.0.3, 3.0.2
Environment: WindowsXP, Java1.6.20 using a RamDirectory
Reporter: Tamas Sandor
I have a code snippet (see below) which creates a new document with standard
(stored, indexed), *not-stored, indexed-only* and some *NumericFields*. Then it
updates the document via adding a new string field. The result is that all the
fields that are not stored but indexed-only and especially NumericFields the
trie tokens are completly lost from index after update or delete/add.
{code:java}
Directory ramDir = new RamDirectory();
IndexWriter writer = new IndexWriter(ramDir, new WhitespaceAnalyzer(),
MaxFieldLength.UNLIMITED);
Document doc = new Document();
doc.add(new Field("ID", "HO1234", Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("PATTERN", "HELLO", Store.NO, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new NumericField("LAT", Store.YES,
true).setDoubleValue(51.488266037777066d));
doc.add(new NumericField("LNG", Store.YES,
true).setDoubleValue(-0.08913399651646614d));
writer.addDocument(doc);
doc = new Document();
doc.add(new Field("ID", "HO2222", Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("PATTERN", "BELLO", Store.NO, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new NumericField("LAT", Store.YES,
true).setDoubleValue(101.488266037777066d));
doc.add(new NumericField("LNG", Store.YES,
true).setDoubleValue(-100.08913399651646614d));
writer.addDocument(doc);
Term t = new Term("ID", "HO1234");
Query q = new TermQuery(t);
IndexSearcher seacher = new IndexSearcher(writer.getReader());
TopDocs hits = seacher.search(q, 1);
if (hits.scoreDocs.length > 0) {
Document ndoc = seacher.doc(hits.scoreDocs[0].doc);
ndoc.add(new Field("FINAL", "FINAL", Store.YES,
Index.NOT_ANALYZED_NO_NORMS));
writer.updateDocument(t, ndoc);
// writer.deleteDocuments(q);
// writer.addDocument(ndoc);
} else {
LOG.info("Couldn't find the document via the query");
}
seacher = new IndexSearcher(writer.getReader());
hits = seacher.search(new TermQuery(new Term("PATTERN", "HELLO")), 1);
LOG.info("_____hits HELLO:" + hits.totalHits); // should be 1 but it's 0
writer.close();
{code}
And I have a boundingbox query based on *NumericRangeQuery*. After the document
update it doesn't return any hit.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]