Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

update/re-add an existing document with numeric fields

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


timeck at gmail

May 8, 2012, 1:08 PM

Post #1 of 10 (429 views)
Permalink
update/re-add an existing document with numeric fields

Note: I'm bound to lucene 3.0.3 for the context of this question, but
I would be interested to know if newer versions would help me here.

I have an existing document in my directory that has one regular
String field and one numeric field. I naively thought I could update
that document to change the String field with code like this:

FSDirectory dir = FSDirectory.open(...);
IndexWriter writer = new IndexWriter(dir, new
StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);

// doc has 2 fields, one String and the other numeric
Document doc = new Document();
doc.add(new Field("string", "value", Store.YES,
Index.ANALYZED_NO_NORMS));
NumericField nf = new NumericField("numeric", Field.Store.YES,
true);
nf.setIntValue(42);
doc.add(nf);
writer.addDocument(doc);
writer.commit();

// make sure we can query on the numeric field
IndexSearcher searcher = new IndexSearcher(dir);
TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError();
}
doc = searcher.doc(docs.scoreDocs[0].doc);
searcher.close();

// update document with new value for string field
doc.removeField("string");
doc.add(new Field("string", "value2", Store.YES,
Index.ANALYZED_NO_NORMS));
writer.updateDocument(new Term("string", "value"), doc);
writer.commit();

// search again
searcher = new IndexSearcher(dir);
docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError(docs.totalHits);
}


That doesn't seem to work however. It seems I need to get the
NumericField rematerialized in the document passed to
updateDocument(). I was hoping to avoid that if possible so
I'm looking for any suggestions someone might offer.




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


timeck at gmail

May 8, 2012, 1:48 PM

Post #2 of 10 (419 views)
Permalink
update/re-add an existing document with numeric fields [In reply to]

Note: I'm bound to lucene 3.0.3 for the context of this question, but
I would be interested to know if newer versions would help me here.

I have an existing document in my directory that has one regular
String field and one numeric field. I naively thought I could update
that document to change the String field with code like this:

FSDirectory dir = FSDirectory.open(...);
IndexWriter writer = new IndexWriter(dir, new
StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);

// doc has 2 fields, one String and the other numeric
Document doc = new Document();
doc.add(new Field("string", "value", Store.YES,
Index.ANALYZED_NO_NORMS));
NumericField nf = new NumericField("numeric", Field.Store.YES,
true);
nf.setIntValue(42);
doc.add(nf);
writer.addDocument(doc);
writer.commit();

// make sure we can query on the numeric field
IndexSearcher searcher = new IndexSearcher(dir);
TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError();
}
doc = searcher.doc(docs.scoreDocs[0].doc);
searcher.close();

// update document with new value for string field
doc.removeField("string");
doc.add(new Field("string", "value2", Store.YES,
Index.ANALYZED_NO_NORMS));
writer.updateDocument(new Term("string", "value"), doc);
writer.commit();

// search again
searcher = new IndexSearcher(dir);
docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError(docs.totalHits);
}


That doesn't seem to work however. It seems I need to get the
NumericField rematerialized in the document passed to
updateDocument(). I was hoping to avoid that if possible so
I'm looking for any suggestions someone might offer.





---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


timeck at gmail

May 9, 2012, 10:21 AM

Post #3 of 10 (412 views)
Permalink
update/re-add an existing document with numeric fields [In reply to]

Note: I'm bound to lucene 3.0.3 for the context of this question, but

I would be interested to know if newer versions would help me here.



I have an existing document in my directory that has one regular

String field and one numeric field. I naively thought I could update

that document to change the String field with code like this:



FSDirectory dir = FSDirectory.open(...);

IndexWriter writer = new IndexWriter(dir, new

StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);



// doc has 2 fields, one String and the other numeric

Document doc = new Document();

doc.add(new Field("string", "value", Store.YES,

Index.ANALYZED_NO_NORMS));

NumericField nf = new NumericField("numeric", Field.Store.YES,

true);

nf.setIntValue(42);

doc.add(nf);

writer.addDocument(doc);

writer.commit();



// make sure we can query on the numeric field

IndexSearcher searcher = new IndexSearcher(dir);

TopDocs docs = searcher.search(new TermQuery(new Term("numeric",

NumericUtils.intToPrefixCoded(42))), 1);

if (docs.totalHits != 1) {

throw new AssertionError();

}

doc = searcher.doc(docs.scoreDocs[0].doc);

searcher.close();



// update document with new value for string field

doc.removeField("string");

doc.add(new Field("string", "value2", Store.YES,

Index.ANALYZED_NO_NORMS));

writer.updateDocument(new Term("string", "value"), doc);

writer.commit();



// search again

searcher = new IndexSearcher(dir);

docs = searcher.search(new TermQuery(new Term("numeric",

NumericUtils.intToPrefixCoded(42))), 1);

if (docs.totalHits != 1) {

throw new AssertionError(docs.totalHits);

}





That doesn't seem to work however. It seems I need to get the

NumericField rematerialized in the document passed to

updateDocument(). I was hoping to avoid that if possible so

I'm looking for any suggestions someone might offer.


timeck at gmail

May 9, 2012, 10:27 AM

Post #4 of 10 (412 views)
Permalink
update/re-add an existing document with numeric fields [In reply to]

Note: I'm bound to lucene 3.0.3 for the context of this question, but

I would be interested to know if newer versions would help me here.



I have an existing document in my directory that has one regular

String field and one numeric field. I naively thought I could update

that document to change the String field with code like this:



FSDirectory dir = FSDirectory.open(...);

IndexWriter writer = new IndexWriter(dir, new

StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);



// doc has 2 fields, one String and the other numeric

Document doc = new Document();

doc.add(new Field("string", "value", Store.YES,

Index.ANALYZED_NO_NORMS));

NumericField nf = new NumericField("numeric", Field.Store.YES,

true);

nf.setIntValue(42);

doc.add(nf);

writer.addDocument(doc);

writer.commit();



// make sure we can query on the numeric field

IndexSearcher searcher = new IndexSearcher(dir);

TopDocs docs = searcher.search(new TermQuery(new Term("numeric",

NumericUtils.intToPrefixCoded(42))), 1);

if (docs.totalHits != 1) {

throw new AssertionError();

}

doc = searcher.doc(docs.scoreDocs[0].doc);

searcher.close();



// update document with new value for string field

doc.removeField("string");

doc.add(new Field("string", "value2", Store.YES,

Index.ANALYZED_NO_NORMS));

writer.updateDocument(new Term("string", "value"), doc);

writer.commit();



// search again

searcher = new IndexSearcher(dir);

docs = searcher.search(new TermQuery(new Term("numeric",

NumericUtils.intToPrefixCoded(42))), 1);

if (docs.totalHits != 1) {

throw new AssertionError(docs.totalHits);

}





That doesn't seem to work however. It seems I need to get the

NumericField rematerialized in the document passed to

updateDocument(). I was hoping to avoid that if possible so

I'm looking for any suggestions someone might offer.


timeck at gmail

May 9, 2012, 10:33 AM

Post #5 of 10 (412 views)
Permalink
update/re-add an existing document with numeric fields [In reply to]

Note: I'm bound to lucene 3.0.3 for the context of this question, but
I would be interested to know if newer versions would help me here.

I have an existing document in my directory that has one regular
String field and one numeric field. I naively thought I could update
that document to change the String field with code like this:

FSDirectory dir = FSDirectory.open(...);
IndexWriter writer = new IndexWriter(dir, new
StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);

// doc has 2 fields, one String and the other numeric
Document doc = new Document();
doc.add(new Field("string", "value", Store.YES,
Index.ANALYZED_NO_NORMS));
NumericField nf = new NumericField("numeric", Field.Store.YES,
true);
nf.setIntValue(42);
doc.add(nf);
writer.addDocument(doc);
writer.commit();

// make sure we can query on the numeric field
IndexSearcher searcher = new IndexSearcher(dir);
TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError();
}
doc = searcher.doc(docs.scoreDocs[0].doc);
searcher.close();

// update document with new value for string field
doc.removeField("string");
doc.add(new Field("string", "value2", Store.YES,
Index.ANALYZED_NO_NORMS));
writer.updateDocument(new Term("string", "value"), doc);
writer.commit();

// search again
searcher = new IndexSearcher(dir);
docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError(docs.totalHits);
}


That doesn't seem to work however. It seems I need to get the
NumericField rematerialized in the document passed to
updateDocument(). I was hoping to avoid that if possible so
I'm looking for any suggestions someone might offer.


teck at terracottatech

May 9, 2012, 10:38 AM

Post #6 of 10 (411 views)
Permalink
update/re-add an existing document with numeric fields [In reply to]

Note: I'm bound to lucene 3.0.3 for the context of this question, but
I would be interested to know if newer versions would help me here.

I have an existing document in my directory that has one regular
String field and one numeric field. I naively thought I could update
that document to change the String field with code like this:

FSDirectory dir = FSDirectory.open(...);
IndexWriter writer = new IndexWriter(dir, new
StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);

// doc has 2 fields, one String and the other numeric
Document doc = new Document();
doc.add(new Field("string", "value", Store.YES,
Index.ANALYZED_NO_NORMS));
NumericField nf = new NumericField("numeric", Field.Store.YES,
true);
nf.setIntValue(42);
doc.add(nf);
writer.addDocument(doc);
writer.commit();

// make sure we can query on the numeric field
IndexSearcher searcher = new IndexSearcher(dir);
TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError();
}
doc = searcher.doc(docs.scoreDocs[0].doc);
searcher.close();

// update document with new value for string field
doc.removeField("string");
doc.add(new Field("string", "value2", Store.YES,
Index.ANALYZED_NO_NORMS));
writer.updateDocument(new Term("string", "value"), doc);
writer.commit();

// search again
searcher = new IndexSearcher(dir);
docs = searcher.search(new TermQuery(new Term("numeric",
NumericUtils.intToPrefixCoded(42))), 1);
if (docs.totalHits != 1) {
throw new AssertionError(docs.totalHits);
}


That doesn't seem to work however. It seems I need to get the
NumericField rematerialized in the document passed to
updateDocument(). I was hoping to avoid that if possible so
I'm looking for any suggestions someone might offer.


ian.lea at gmail

May 10, 2012, 1:20 AM

Post #7 of 10 (403 views)
Permalink
Re: update/re-add an existing document with numeric fields [In reply to]

You can't selectively update fields in docs read from an index, in old
or current versions of lucene. I think there are some ideas floating
around but nothing usable today as far as I know. You'll need to
rebuild the whole doc before passing it to writer.updateDocument().


--
Ian.


On Wed, May 9, 2012 at 6:38 PM, Tim Eck <teck [at] terracottatech> wrote:
> Note: I'm bound to lucene 3.0.3 for the context of this question, but
> I would be interested to know if newer versions would help me here.
>
> I have an existing document in my directory that has one regular
> String field and one numeric field. I naively thought I could update
> that document to change the String field with code like this:
>
>  FSDirectory dir = FSDirectory.open(...);
>  IndexWriter writer = new IndexWriter(dir, new
>      StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);
>
>  // doc has 2 fields, one String and the other numeric
>  Document doc = new Document();
>  doc.add(new Field("string", "value", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  NumericField nf = new NumericField("numeric", Field.Store.YES,
>      true);
>  nf.setIntValue(42);
>  doc.add(nf);
>  writer.addDocument(doc);
>  writer.commit();
>
>  // make sure we can query on the numeric field
>  IndexSearcher searcher = new IndexSearcher(dir);
>  TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError();
>  }
>  doc = searcher.doc(docs.scoreDocs[0].doc);
>  searcher.close();
>
>  // update document with new value for string field
>  doc.removeField("string");
>  doc.add(new Field("string", "value2", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  writer.updateDocument(new Term("string", "value"), doc);
>  writer.commit();
>
>  // search again
>  searcher = new IndexSearcher(dir);
>  docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError(docs.totalHits);
>  }
>
>
> That doesn't seem to work however. It seems I need to get the
> NumericField rematerialized in the document passed to
> updateDocument(). I was hoping to avoid that if possible so
> I'm looking for any suggestions someone might offer.
>
>
>
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


teck at terracottatech

May 10, 2012, 1:26 AM

Post #8 of 10 (404 views)
Permalink
RE: update/re-add an existing document with numeric fields [In reply to]

Thanks for the response (and sorry for the excessive duplicate posting to
the list, that obviously wasn't on purpose).

I should have explicitly asked this, but one specific thing I wondered was
whether LUCENE-3065 would make any difference in my example program (I
haven't had time to test it yet)

In the meantime I have gone through the motions to rebuild my doc from
whole cloth and I'm reasonably sure it is working me :-)

Thanks!

-----Original Message-----
From: Ian Lea [mailto:ian.lea [at] gmail]
Sent: Thursday, May 10, 2012 1:20 AM
To: java-user [at] lucene
Subject: Re: update/re-add an existing document with numeric fields

You can't selectively update fields in docs read from an index, in old
or current versions of lucene. I think there are some ideas floating
around but nothing usable today as far as I know. You'll need to
rebuild the whole doc before passing it to writer.updateDocument().


--
Ian.


On Wed, May 9, 2012 at 6:38 PM, Tim Eck <teck [at] terracottatech> wrote:
> Note: I'm bound to lucene 3.0.3 for the context of this question, but
> I would be interested to know if newer versions would help me here.
>
> I have an existing document in my directory that has one regular
> String field and one numeric field. I naively thought I could update
> that document to change the String field with code like this:
>
>  FSDirectory dir = FSDirectory.open(...);
>  IndexWriter writer = new IndexWriter(dir, new
>      StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);
>
>  // doc has 2 fields, one String and the other numeric
>  Document doc = new Document();
>  doc.add(new Field("string", "value", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  NumericField nf = new NumericField("numeric", Field.Store.YES,
>      true);
>  nf.setIntValue(42);
>  doc.add(nf);
>  writer.addDocument(doc);
>  writer.commit();
>
>  // make sure we can query on the numeric field
>  IndexSearcher searcher = new IndexSearcher(dir);
>  TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError();
>  }
>  doc = searcher.doc(docs.scoreDocs[0].doc);
>  searcher.close();
>
>  // update document with new value for string field
>  doc.removeField("string");
>  doc.add(new Field("string", "value2", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  writer.updateDocument(new Term("string", "value"), doc);
>  writer.commit();
>
>  // search again
>  searcher = new IndexSearcher(dir);
>  docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError(docs.totalHits);
>  }
>
>
> That doesn't seem to work however. It seems I need to get the
> NumericField rematerialized in the document passed to
> updateDocument(). I was hoping to avoid that if possible so
> I'm looking for any suggestions someone might offer.
>
>
>
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


ian.lea at gmail

May 10, 2012, 1:43 AM

Post #9 of 10 (410 views)
Permalink
Re: update/re-add an existing document with numeric fields [In reply to]

My guess is that LUCENE-3065 won't help. Couldn't do the read/update
stuff before NumericFields came along and still can't, with or without
that patch.


--
Ian.


On Thu, May 10, 2012 at 9:26 AM, Tim Eck <teck [at] terracottatech> wrote:
> Thanks for the response (and sorry for the excessive duplicate posting to
> the list, that obviously wasn't on purpose).
>
> I should have explicitly asked this, but one specific thing I wondered was
> whether LUCENE-3065 would make any difference in my example program (I
> haven't had time to test it yet)
>
> In the meantime I have gone through the motions to rebuild my doc from
> whole cloth and I'm reasonably sure it is working me :-)
>
> Thanks!
>
> -----Original Message-----
> From: Ian Lea [mailto:ian.lea [at] gmail]
> Sent: Thursday, May 10, 2012 1:20 AM
> To: java-user [at] lucene
> Subject: Re: update/re-add an existing document with numeric fields
>
> You can't selectively update fields in docs read from an index, in old
> or current versions of lucene.  I think there are some ideas floating
> around but nothing usable today as far as I know.  You'll need to
> rebuild the whole doc before passing it to writer.updateDocument().
>
>
> --
> Ian.
>
>
> On Wed, May 9, 2012 at 6:38 PM, Tim Eck <teck [at] terracottatech> wrote:
>> Note: I'm bound to lucene 3.0.3 for the context of this question, but
>> I would be interested to know if newer versions would help me here.
>>
>> I have an existing document in my directory that has one regular
>> String field and one numeric field. I naively thought I could update
>> that document to change the String field with code like this:
>>
>> áFSDirectory dir = FSDirectory.open(...);
>> áIndexWriter writer = new IndexWriter(dir, new
>> á á áStandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);
>>
>> á// doc has 2 fields, one String and the other numeric
>> áDocument doc = new Document();
>> ádoc.add(new Field("string", "value", Store.YES,
>> á á áIndex.ANALYZED_NO_NORMS));
>> áNumericField nf = new NumericField("numeric", Field.Store.YES,
>> á á átrue);
>> ánf.setIntValue(42);
>> ádoc.add(nf);
>> áwriter.addDocument(doc);
>> áwriter.commit();
>>
>> á// make sure we can query on the numeric field
>> áIndexSearcher searcher = new IndexSearcher(dir);
>> áTopDocs docs = searcher.search(new TermQuery(new Term("numeric",
>> á á áNumericUtils.intToPrefixCoded(42))), 1);
>> áif (docs.totalHits != 1) {
>> á á áthrow new AssertionError();
>> á}
>> ádoc = searcher.doc(docs.scoreDocs[0].doc);
>> ásearcher.close();
>>
>> á// update document with new value for string field
>> ádoc.removeField("string");
>> ádoc.add(new Field("string", "value2", Store.YES,
>> á á áIndex.ANALYZED_NO_NORMS));
>> áwriter.updateDocument(new Term("string", "value"), doc);
>> áwriter.commit();
>>
>> á// search again
>> ásearcher = new IndexSearcher(dir);
>> ádocs = searcher.search(new TermQuery(new Term("numeric",
>> á á áNumericUtils.intToPrefixCoded(42))), 1);
>> áif (docs.totalHits != 1) {
>> á á áthrow new AssertionError(docs.totalHits);
>> á}
>>
>>
>> That doesn't seem to work however. It seems I need to get the
>> NumericField rematerialized in the document passed to
>> updateDocument(). I was hoping to avoid that if possible so
>> I'm looking for any suggestions someone might offer.
>>
>>
>>
>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


lucene at mikemccandless

May 10, 2012, 2:58 AM

Post #10 of 10 (399 views)
Permalink
Re: update/re-add an existing document with numeric fields [In reply to]

This is actually due to a bug:

https://issues.apache.org/jira/browse/LUCENE-3065

which was ixed in 3.2. The bug is that, prior to Lucene 3.2, if you
stored a NumericField, when you later load that document, the field is
converted to an ordinary Field (no longer numeric), so when you then
index that retrieved document you lost its numeric-ness.

That said, retrieving a doc and reindexing it is dangerous because in
general Lucene does not ensure all details are preserved. For
example, boost is never returned correctly, whether a field was
indexed, and whether term vectors were indexed, are all not preserved.
So in general you shouldn't assume you can just load a document,
modify it a bit, re-index it, and not lose something...

Mike McCandless

http://blog.mikemccandless.com

On Wed, May 9, 2012 at 1:33 PM, Tim Eck <timeck [at] gmail> wrote:
> Note: I'm bound to lucene 3.0.3 for the context of this question, but
> I would be interested to know if newer versions would help me here.
>
> I have an existing document in my directory that has one regular
> String field and one numeric field. I naively thought I could update
> that document to change the String field with code like this:
>
>  FSDirectory dir = FSDirectory.open(...);
>  IndexWriter writer = new IndexWriter(dir, new
>      StandardAnalyzer(Version.LUCENE_30), MaxFieldLength.UNLIMITED);
>
>  // doc has 2 fields, one String and the other numeric
>  Document doc = new Document();
>  doc.add(new Field("string", "value", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  NumericField nf = new NumericField("numeric", Field.Store.YES,
>      true);
>  nf.setIntValue(42);
>  doc.add(nf);
>  writer.addDocument(doc);
>  writer.commit();
>
>  // make sure we can query on the numeric field
>  IndexSearcher searcher = new IndexSearcher(dir);
>  TopDocs docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError();
>  }
>  doc = searcher.doc(docs.scoreDocs[0].doc);
>  searcher.close();
>
>  // update document with new value for string field
>  doc.removeField("string");
>  doc.add(new Field("string", "value2", Store.YES,
>      Index.ANALYZED_NO_NORMS));
>  writer.updateDocument(new Term("string", "value"), doc);
>  writer.commit();
>
>  // search again
>  searcher = new IndexSearcher(dir);
>  docs = searcher.search(new TermQuery(new Term("numeric",
>      NumericUtils.intToPrefixCoded(42))), 1);
>  if (docs.totalHits != 1) {
>      throw new AssertionError(docs.totalHits);
>  }
>
>
> That doesn't seem to work however. It seems I need to get the
> NumericField rematerialized in the document passed to
> updateDocument(). I was hoping to avoid that if possible so
> I'm looking for any suggestions someone might offer.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.