lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: [jira] Created: (LUCENE-2863) Updating a documenting looses its fields that only indexed, also NumericField tries are completely lost
Date Fri, 14 Jan 2011 19:08:46 GMT
This is behaving as intended if I'm reading this correctly. Lucene has
never fetched fields that aren't stored, and that's what you're
asking it to do. To see why, consider indexing but not storing
a normal text field with, say stop word removal and stemming. The
*only* data kept in the index is the analyzed data, so even if you
did reconstruct the field (no easy task BTW), you'd have something that
was not the original text and would be pretty unsatisfactory.

Kudos for providing the test case by the way, that makes figuring out
what the answer is much easier...

If this makes sense, could you close the JIRA? If not we can hash
it out a bit more...

Best
Erick

On Wed, Jan 12, 2011 at 2:12 PM, Tamas Sandor (JIRA) <jira@apache.org>wrote:

> 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: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

Mime
View raw message