You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by João Silva <ga...@gmail.com> on 2009/06/19 00:20:38 UTC

update a specific document

Hi,
I want to update a specific document,
but i didn't found updateDocument(Query)
or updateDocument(Term[]), so to make
a update, i will need to have a term with an
unique id, so a retrieve a u)nique document,
There's any way of access the internal document
id?
For example, imagine that i have the id of document
to update, and i want to update(Term,Document) but passing
the internal id as Term.

cheers,
João


-- 
Cumprimentos,
João Carlos Galaio da Silva

Re: update a specific document

Posted by Daan de Wit <d....@o3spaces.com>.
Oops, didn't read the OP quite well...

2009/6/19 Anshum <an...@gmail.com>:
> Exactly, its cleaner but you wouldn't be able to delete on the basis of
> Lucene Document ID.
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Fri, Jun 19, 2009 at 1:26 PM, Daan de Wit <d....@o3spaces.com> wrote:
>
>> There's also IndexWriter#updateDocument(Term, Document) now, to use
>> that one you need to be able to uniquely identify a document using a
>> term (probably with an application-specific id field or something).
>> This method does also delete and readd the document, but it is a
>> somewhat cleaner api.
>>
>> Daan
>>
>> 2009/6/19 Anshum <an...@gmail.com>:
>> > HI Galaio,
>> > To update a document in lucene this way, you'd have to first delete the
>> > document
>> > using indexReader's delete document and then readd the document (thereby
>> > changing the internal docId as well).
>> > You may use:
>> >
>> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument(int)<http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument%28int%29>
>> >
>> >
>> > --
>> > Anshum Gupta
>> > Naukri Labs!
>> > http://ai-cafe.blogspot.com
>> >
>> > The facts expressed here belong to everybody, the opinions to me. The
>> > distinction is yours to draw............
>> >
>> >
>> > On Fri, Jun 19, 2009 at 3:50 AM, João Silva <ga...@gmail.com>
>> wrote:
>> >
>> >> Hi,
>> >> I want to update a specific document,
>> >> but i didn't found updateDocument(Query)
>> >> or updateDocument(Term[]), so to make
>> >> a update, i will need to have a term with an
>> >> unique id, so a retrieve a u)nique document,
>> >> There's any way of access the internal document
>> >> id?
>> >> For example, imagine that i have the id of document
>> >> to update, and i want to update(Term,Document) but passing
>> >> the internal id as Term.
>> >>
>> >> cheers,
>> >> João
>> >>
>> >>
>> >> --
>> >> Cumprimentos,
>> >> João Carlos Galaio da Silva
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: update a specific document

Posted by João Silva <ga...@gmail.com>.
Hi,
thank you all for your answers. I already done the strategies you mencioned
by delete first and update or using the internal api updateDocument(term,
document).
If there was  a updateDocument(internalid, theNewDocument) present
in the api, this clarified more the process.

Thanks again, for your fast answers,
i will do with a specific application id in one term.

--
Galaio da Silva


On Fri, Jun 19, 2009 at 9:09 AM, Anshum <an...@gmail.com> wrote:

> Exactly, its cleaner but you wouldn't be able to delete on the basis of
> Lucene Document ID.
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Fri, Jun 19, 2009 at 1:26 PM, Daan de Wit <d....@o3spaces.com>
> wrote:
>
> > There's also IndexWriter#updateDocument(Term, Document) now, to use
> > that one you need to be able to uniquely identify a document using a
> > term (probably with an application-specific id field or something).
> > This method does also delete and readd the document, but it is a
> > somewhat cleaner api.
> >
> > Daan
> >
> > 2009/6/19 Anshum <an...@gmail.com>:
> > > HI Galaio,
> > > To update a document in lucene this way, you'd have to first delete the
> > > document
> > > using indexReader's delete document and then readd the document
> (thereby
> > > changing the internal docId as well).
> > > You may use:
> > >
> >
> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument(int)<http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument%28int%29>
> <
> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument%28int%29
> >
> > >
> > >
> > > --
> > > Anshum Gupta
> > > Naukri Labs!
> > > http://ai-cafe.blogspot.com
> > >
> > > The facts expressed here belong to everybody, the opinions to me. The
> > > distinction is yours to draw............
> > >
> > >
> > > On Fri, Jun 19, 2009 at 3:50 AM, João Silva <ga...@gmail.com>
> > wrote:
> > >
> > >> Hi,
> > >> I want to update a specific document,
> > >> but i didn't found updateDocument(Query)
> > >> or updateDocument(Term[]), so to make
> > >> a update, i will need to have a term with an
> > >> unique id, so a retrieve a u)nique document,
> > >> There's any way of access the internal document
> > >> id?
> > >> For example, imagine that i have the id of document
> > >> to update, and i want to update(Term,Document) but passing
> > >> the internal id as Term.
> > >>
> > >> cheers,
> > >> João
> > >>
> > >>
> > >> --
> > >> Cumprimentos,
> > >> João Carlos Galaio da Silva
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>



-- 
Cumprimentos,
João Carlos Galaio da Silva

Re: update a specific document

Posted by Anshum <an...@gmail.com>.
Exactly, its cleaner but you wouldn't be able to delete on the basis of
Lucene Document ID.

--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............


On Fri, Jun 19, 2009 at 1:26 PM, Daan de Wit <d....@o3spaces.com> wrote:

> There's also IndexWriter#updateDocument(Term, Document) now, to use
> that one you need to be able to uniquely identify a document using a
> term (probably with an application-specific id field or something).
> This method does also delete and readd the document, but it is a
> somewhat cleaner api.
>
> Daan
>
> 2009/6/19 Anshum <an...@gmail.com>:
> > HI Galaio,
> > To update a document in lucene this way, you'd have to first delete the
> > document
> > using indexReader's delete document and then readd the document (thereby
> > changing the internal docId as well).
> > You may use:
> >
> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument(int)<http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument%28int%29>
> >
> >
> > --
> > Anshum Gupta
> > Naukri Labs!
> > http://ai-cafe.blogspot.com
> >
> > The facts expressed here belong to everybody, the opinions to me. The
> > distinction is yours to draw............
> >
> >
> > On Fri, Jun 19, 2009 at 3:50 AM, João Silva <ga...@gmail.com>
> wrote:
> >
> >> Hi,
> >> I want to update a specific document,
> >> but i didn't found updateDocument(Query)
> >> or updateDocument(Term[]), so to make
> >> a update, i will need to have a term with an
> >> unique id, so a retrieve a u)nique document,
> >> There's any way of access the internal document
> >> id?
> >> For example, imagine that i have the id of document
> >> to update, and i want to update(Term,Document) but passing
> >> the internal id as Term.
> >>
> >> cheers,
> >> João
> >>
> >>
> >> --
> >> Cumprimentos,
> >> João Carlos Galaio da Silva
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: update a specific document

Posted by Daan de Wit <d....@o3spaces.com>.
There's also IndexWriter#updateDocument(Term, Document) now, to use
that one you need to be able to uniquely identify a document using a
term (probably with an application-specific id field or something).
This method does also delete and readd the document, but it is a
somewhat cleaner api.

Daan

2009/6/19 Anshum <an...@gmail.com>:
> HI Galaio,
> To update a document in lucene this way, you'd have to first delete the
> document
> using indexReader's delete document and then readd the document (thereby
> changing the internal docId as well).
> You may use:
> http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument(int)
>
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Fri, Jun 19, 2009 at 3:50 AM, João Silva <ga...@gmail.com> wrote:
>
>> Hi,
>> I want to update a specific document,
>> but i didn't found updateDocument(Query)
>> or updateDocument(Term[]), so to make
>> a update, i will need to have a term with an
>> unique id, so a retrieve a u)nique document,
>> There's any way of access the internal document
>> id?
>> For example, imagine that i have the id of document
>> to update, and i want to update(Term,Document) but passing
>> the internal id as Term.
>>
>> cheers,
>> João
>>
>>
>> --
>> Cumprimentos,
>> João Carlos Galaio da Silva
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: update a specific document

Posted by Anshum <an...@gmail.com>.
HI Galaio,
To update a document in lucene this way, you'd have to first delete the
document
using indexReader's delete document and then readd the document (thereby
changing the internal docId as well).
You may use:
http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/index/IndexReader.html#deleteDocument(int)


--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............


On Fri, Jun 19, 2009 at 3:50 AM, João Silva <ga...@gmail.com> wrote:

> Hi,
> I want to update a specific document,
> but i didn't found updateDocument(Query)
> or updateDocument(Term[]), so to make
> a update, i will need to have a term with an
> unique id, so a retrieve a u)nique document,
> There's any way of access the internal document
> id?
> For example, imagine that i have the id of document
> to update, and i want to update(Term,Document) but passing
> the internal id as Term.
>
> cheers,
> João
>
>
> --
> Cumprimentos,
> João Carlos Galaio da Silva
>