Re: updating the index created for database search

2004-07-27 Thread lingaraju
I tried but I am missing some thing
Please can you tell me the syntax how to use the TermQuery to check the
presence of document in index from key field say OID

- Original Message - 
From: "Daniel Naber" <[EMAIL PROTECTED]>
To: "Lucene Users List" <[EMAIL PROTECTED]>
Sent: Monday, July 26, 2004 5:21 PM
Subject: Re: updating the index created for database search


> On Monday 26 July 2004 13:31, lingaraju wrote:
>
> > If it is new record  through which class we have to check that record is
> > present in the index
>
> Just search for the id with a TermQuery. If you get a hit, the record is
in
> the index already.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: updating the index created for database search

2004-07-26 Thread Stephane James Vaucher
Firstly, please do not double-post, other comments inline:

On Mon, 26 Jul 2004, lingaraju wrote:

> Dear  All
> 
> I need  help  to  update the index created for the database search
> 
> I created the index with  three field  mapping to the three column of 
> database(oid(primarykey),title, contents)
> Then I created the document for each row and added to the writer  
> 
> doc.add(Field.Keyword("OID",oid+""));
> doc.add(Field.Text("title",title));
> doc.add(Field.Text("contents",contents));
> writer.addDocument(doc);
> 
> Here search is only on  title and the contents and oid is the key to retrieve the 
> details from the database.
> 
> Later if the "contents" column in the database is  updated. We have to updated the 
> content in the index also
> 
> If I use the writer with false
> 
> IndexWriter writer = new IndexWriter("C\index", new StandardAnalyzer(),false);
> 
> then all the record are inserted in to index without deleting the old index causing 
> duplication

It's a question of efficiency. The procedure for doing updates is 
described here:

http://wiki.apache.org/jakarta-lucene/UpdatingAnIndex

In a nutshell, it's up to you to decide when a record is modified and 
needs to be removed, then readded (there is no update)

> If I use the writer with true
> 
> IndexWriter writer = new IndexWriter("C\index", new StandardAnalyzer(),false);
> 
> then record are inserted in to index deleting all the old index.
> 
> My question is 
> 1) How to update the existing index 
> 2) When I fetch the rows from the database in order to update or insert in index how 
> to know which record is modified in database and which record is not present is index
> 
> Thanks is advance
> Raju
> 

sv


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: updating the index created for database search

2004-07-26 Thread lingaraju
Dear Daniel

Thakns
Secod part is ok  What about the first part I mean "how to know how many
records are modified"

Regards
Raju

- Original Message - 
From: "Daniel Naber" <[EMAIL PROTECTED]>
To: "Lucene Users List" <[EMAIL PROTECTED]>
Sent: Monday, July 26, 2004 5:21 PM
Subject: Re: updating the index created for database search


> On Monday 26 July 2004 13:31, lingaraju wrote:
>
> > If it is new record  through which class we have to check that record is
> > present in the index
>
> Just search for the id with a TermQuery. If you get a hit, the record is
in
> the index already.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: updating the index created for database search

2004-07-26 Thread Daniel Naber
On Monday 26 July 2004 13:31, lingaraju wrote:

> If it is new record  through which class we have to check that record is
> present in the index

Just search for the id with a TermQuery. If you get a hit, the record is in 
the index already.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: updating the index created for database search

2004-07-26 Thread lingaraju
Dear Daniel

Thanks a lot.
I do have the last-modified column in my database.
But how to know how many records are modified.
If it is new record  through which class we have to check that record is
present in the index
In the mean time I will look into IndexHTML in lucene demo

Regards
Raju

- Original Message - 
From: "Daniel Naber" <[EMAIL PROTECTED]>
To: "Lucene Users List" <[EMAIL PROTECTED]>
Sent: Monday, July 26, 2004 3:35 PM
Subject: Re: updating the index created for database search


> On Monday 26 July 2004 11:37, lingaraju wrote:
>
> > 2) When I fetch the rows from the database in order to update or insert
in
> > index how to know which record is modified in database and which record
is
> > not present is index
>
> Your database will need a "last modified" column. Then you can select
those
> rows that have been modified since the last update and for each row check
if
> it's in the Lucene index. If it is, delete it there and re-add the new
> version. If it's not, add it. To delete documents you will probably need
to
> iterate over all your IDs in the Lucene index and check if they are still
in
> the database. If that's too inefficient you could check if you can do it
the
> way the file system indexer (IndexHTML in Lucene's demo) does it.
>
> BTW, please don't cross-post to both lists.
>
> Regards
>  Daniel
>
> -- 
> Daniel Naber, IntraFind Software AG, Tel. 089-8906 9700
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: updating the index created for database search

2004-07-26 Thread Daniel Naber
On Monday 26 July 2004 11:37, lingaraju wrote:

> 2) When I fetch the rows from the database in order to update or insert in
> index how to know which record is modified in database and which record is
> not present is index

Your database will need a "last modified" column. Then you can select those 
rows that have been modified since the last update and for each row check if 
it's in the Lucene index. If it is, delete it there and re-add the new 
version. If it's not, add it. To delete documents you will probably need to 
iterate over all your IDs in the Lucene index and check if they are still in 
the database. If that's too inefficient you could check if you can do it the 
way the file system indexer (IndexHTML in Lucene's demo) does it.

BTW, please don't cross-post to both lists.

Regards
 Daniel
 
-- 
Daniel Naber, IntraFind Software AG, Tel. 089-8906 9700


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



updating the index created for database search

2004-07-26 Thread lingaraju
Dear  All

I need  help  to  update the index created for the database search

I created the index with  three field  mapping to the three column of 
database(oid(primarykey),title, contents)
Then I created the document for each row and added to the writer  

doc.add(Field.Keyword("OID",oid+""));
doc.add(Field.Text("title",title));
doc.add(Field.Text("contents",contents));
writer.addDocument(doc);

Here search is only on  title and the contents and oid is the key to retrieve the 
details from the database.

Later if the "contents" column in the database is  updated. We have to updated the 
content in the index also

If I use the writer with false

IndexWriter writer = new IndexWriter("C\index", new StandardAnalyzer(),false);

then all the record are inserted in to index without deleting the old index causing 
duplication 


If I use the writer with true

IndexWriter writer = new IndexWriter("C\index", new StandardAnalyzer(),false);

then record are inserted in to index deleting all the old index.

My question is 
1) How to update the existing index 
2) When I fetch the rows from the database in order to update or insert in index how 
to know which record is modified in database and which record is not present is index

Thanks is advance
Raju