You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Rob Vesse <rv...@dotnetrdf.org> on 2012/02/09 01:53:48 UTC

[Lucene.Net] Problems with IndexSearcher

Hi All


I'm having an issue with IndexSearcher which I'm confused by, this may just 
be that I don't fully understand all the intricacies of how Lucene works or 
it may be a bug I really have no idea but I'd appreciate it if someone 
could enlighten me.


My problem boils down to inconsistent behavior of the IndexSearcher, if I 
create it and then subsequently make changes to the index it is unable to 
see those changes even if I have called commit() on the IndexWriter used to 
make changes.


e.g.


//Load Index

//Create Searcher

//Modify Index and Commit

//PROBLEM - Searcher cannot see changes


However if I create it after I've committed the changes then it can see 
those changes fine.


e.g.


//Load Index

//Modify Index and Commit

//Create Searcher

//OK - Searcher sees changes fine


So is this the expected behavior of an IndexSearcher or is it a bug?


If it is expected behavior is there some workaround i.e. some method I can 
call that ensures that it always see's changes to the index as soon as they 
are committed or am I literally forced to recreate my IndexSearcher every 
time I change my index.  This seems kinda dumb so I feel like I've maybe 
missed something here and I'm just using the code wrong?


Any guidance would be much appreciated


Cheers,


Rob




Re: [Lucene.Net] Problems with IndexSearcher

Posted by Robert Vesse <rv...@dotnetrdf.org>.
Thanks for the clarification

Franklin - thanks for pointing me to those methods, they do exactly what I want and solve my issue perfectly :-)

Cheers,

Rob

On Feb 9, 2012, at 6:18 AM, Franklin Simmons wrote:

> The behavior is correct.  At least with Lucene.Net 2.3.1, see IndexReader.IsCurrent() and IndexReader.Reopen().
> 
> 
> -----Original Message-----
> From: Rob Vesse [mailto:rvesse@dotnetrdf.org] 
> Sent: Wednesday, February 08, 2012 7:54 PM
> To: lucene-net-user@lucene.apache.org
> Subject: [Lucene.Net] Problems with IndexSearcher
> 
> Hi All
> 
> 
> I'm having an issue with IndexSearcher which I'm confused by, this may just be that I don't fully understand all the intricacies of how Lucene works or it may be a bug I really have no idea but I'd appreciate it if someone could enlighten me.
> 
> 
> My problem boils down to inconsistent behavior of the IndexSearcher, if I create it and then subsequently make changes to the index it is unable to see those changes even if I have called commit() on the IndexWriter used to make changes.
> 
> 
> e.g.
> 
> 
> //Load Index
> 
> //Create Searcher
> 
> //Modify Index and Commit
> 
> //PROBLEM - Searcher cannot see changes
> 
> 
> However if I create it after I've committed the changes then it can see those changes fine.
> 
> 
> e.g.
> 
> 
> //Load Index
> 
> //Modify Index and Commit
> 
> //Create Searcher
> 
> //OK - Searcher sees changes fine
> 
> 
> So is this the expected behavior of an IndexSearcher or is it a bug?
> 
> 
> If it is expected behavior is there some workaround i.e. some method I can 
> call that ensures that it always see's changes to the index as soon as they 
> are committed or am I literally forced to recreate my IndexSearcher every 
> time I change my index.  This seems kinda dumb so I feel like I've maybe 
> missed something here and I'm just using the code wrong?
> 
> 
> Any guidance would be much appreciated
> 
> 
> Cheers,
> 
> 
> Rob
> 
> 
> 
> 




RE: [Lucene.Net] Problems with IndexSearcher

Posted by Franklin Simmons <fs...@sccmediaserver.com>.
The behavior is correct.  At least with Lucene.Net 2.3.1, see IndexReader.IsCurrent() and IndexReader.Reopen().


-----Original Message-----
From: Rob Vesse [mailto:rvesse@dotnetrdf.org] 
Sent: Wednesday, February 08, 2012 7:54 PM
To: lucene-net-user@lucene.apache.org
Subject: [Lucene.Net] Problems with IndexSearcher

Hi All


I'm having an issue with IndexSearcher which I'm confused by, this may just be that I don't fully understand all the intricacies of how Lucene works or it may be a bug I really have no idea but I'd appreciate it if someone could enlighten me.


My problem boils down to inconsistent behavior of the IndexSearcher, if I create it and then subsequently make changes to the index it is unable to see those changes even if I have called commit() on the IndexWriter used to make changes.


e.g.


//Load Index

//Create Searcher

//Modify Index and Commit

//PROBLEM - Searcher cannot see changes


However if I create it after I've committed the changes then it can see those changes fine.


e.g.


//Load Index

//Modify Index and Commit

//Create Searcher

//OK - Searcher sees changes fine


So is this the expected behavior of an IndexSearcher or is it a bug?


If it is expected behavior is there some workaround i.e. some method I can 
call that ensures that it always see's changes to the index as soon as they 
are committed or am I literally forced to recreate my IndexSearcher every 
time I change my index.  This seems kinda dumb so I feel like I've maybe 
missed something here and I'm just using the code wrong?


Any guidance would be much appreciated


Cheers,


Rob





RE: [Lucene.Net] Problems with IndexSearcher

Posted by Digy <di...@gmail.com>.
Rob, 

Yes this is an expected behavior. You have to reopen the searcher to see the
changes. 

You can also use NRT search where IndexWriter's GetReader method is used to
make searches.

http://wiki.apache.org/lucene-java/NearRealtimeSearch

DIGY

-----Original Message-----
From: Rob Vesse [mailto:rvesse@dotnetrdf.org] 
Sent: Thursday, February 09, 2012 2:54 AM
To: lucene-net-user@lucene.apache.org
Subject: [Lucene.Net] Problems with IndexSearcher

Hi All


I'm having an issue with IndexSearcher which I'm confused by, this may just 
be that I don't fully understand all the intricacies of how Lucene works or 
it may be a bug I really have no idea but I'd appreciate it if someone 
could enlighten me.


My problem boils down to inconsistent behavior of the IndexSearcher, if I 
create it and then subsequently make changes to the index it is unable to 
see those changes even if I have called commit() on the IndexWriter used to 
make changes.


e.g.


//Load Index

//Create Searcher

//Modify Index and Commit

//PROBLEM - Searcher cannot see changes


However if I create it after I've committed the changes then it can see 
those changes fine.


e.g.


//Load Index

//Modify Index and Commit

//Create Searcher

//OK - Searcher sees changes fine


So is this the expected behavior of an IndexSearcher or is it a bug?


If it is expected behavior is there some workaround i.e. some method I can 
call that ensures that it always see's changes to the index as soon as they 
are committed or am I literally forced to recreate my IndexSearcher every 
time I change my index.  This seems kinda dumb so I feel like I've maybe 
missed something here and I'm just using the code wrong?


Any guidance would be much appreciated


Cheers,


Rob




-----

Checked by AVG - www.avg.com
Version: 2012.0.1913 / Virus Database: 2112/4798 - Release Date: 02/09/12