You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by rockacola <ro...@gmail.com> on 2009/03/23 02:15:03 UTC
Are you able to list everything in index
I am using Lucene.Net 1.3.3.1 and I am trying to list all searchable item in
the search index.
So basically, without searching but simply return all entries in the index
with customized sorting as well. Can this be achieved?
--
View this message in context: http://www.nabble.com/Are-you-able-to-list-everything-in-index-tp22652917p22652917.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Are you able to list everything in index
Posted by rockacola <ro...@gmail.com>.
Hi Ted,
Yes, as I get comfortable with Lucene (and .NET in general) I'll wrap my
code with error checking and exception handlings.
Besides deletion and lock on physical index file, is there any things I
should look out for when using IndexReader?
Also, I can relie on MaxDoc() right? with pre-assumption of no one modifying
the index file(s) when the program is accessing it.
Thank you,
Regards
Ted Dunning wrote:
>
> This only mostly works. You should also check for deleted documents or
> verify that isn't an issue for you. The document numbers in the range you
> are looking at *are* guaranteed to correspond to a document that has been
> added to the index, but if that document is deleted, then the number is
> not
> re-used until you compress or optimize the index. The results is that
> MaxDoc may be larger than the number of documents in the index and your
> code
> will throw an exception.
>
--
View this message in context: http://www.nabble.com/Are-you-able-to-list-everything-in-index-tp22652917p22671258.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Are you able to list everything in index
Posted by Ted Dunning <te...@gmail.com>.
This only mostly works. You should also check for deleted documents or
verify that isn't an issue for you. The document numbers in the range you
are looking at *are* guaranteed to correspond to a document that has been
added to the index, but if that document is deleted, then the number is not
re-used until you compress or optimize the index. The results is that
MaxDoc may be larger than the number of documents in the index and your code
will throw an exception.
On Mon, Mar 23, 2009 at 3:48 PM, rockacola <ro...@gmail.com> wrote:
>
> Hi Evert,
>
> Thanks for your tip, it actually gave me a hint toward my desired solution!
> This is what I've end up with:
>
> public static List<Document> GetAll(string physicalIndexDirectory)
> {
> List<Document> list = new List<Document>();
> IndexReader ir = IndexReader.Open(physicalIndexDirectory);
>
> for (int i = 0; i < ir.MaxDoc(); i++)
> {
> list.Add(ir.Document(i));
> }
>
> return list;
> }
>
>
>
Re: Are you able to list everything in index
Posted by rockacola <ro...@gmail.com>.
Hi Evert,
Thanks for your tip, it actually gave me a hint toward my desired solution!
This is what I've end up with:
public static List<Document> GetAll(string physicalIndexDirectory)
{
List<Document> list = new List<Document>();
IndexReader ir = IndexReader.Open(physicalIndexDirectory);
for (int i = 0; i < ir.MaxDoc(); i++)
{
list.Add(ir.Document(i));
}
return list;
}
Regards.
Evert Wagenaar wrote:
>
> Hi Racola,
>
> You can get all the Terms from the Index from the IndexReader like in the
> code below. I'm uding Luvene Java and don't know much of .Net. But
> customized sorting can easily be done with a the Set collections (Like
> SortedSet).
>
> Regards,
>
> Evert
>
>
> Directory dir = FSDirectory.getDirectory(indexLocation);
> IndexReader reader = IndexReader.open(dir);
> TermEnum terms = reader.terms();
>
>
>
--
View this message in context: http://www.nabble.com/Are-you-able-to-list-everything-in-index-tp22652917p22670970.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Are you able to list everything in index
Posted by Evert Wagenaar <ev...@gmail.com>.
Hi Racola,
You can get all the Terms from the Index from the IndexReader like in the
code below. I'm uding Luvene Java and don't know much of .Net. But
customized sorting can easily be done with a the Set collections (Like
SortedSet).
Regards,
Evert
Directory dir = FSDirectory.getDirectory(indexLocation);
IndexReader reader = IndexReader.open(dir);
TermEnum terms = reader.terms();
On Mon, Mar 23, 2009 at 2:15 AM, rockacola <ro...@gmail.com> wrote:
>
> I am using Lucene.Net 1.3.3.1 and I am trying to list all searchable item
> in
> the search index.
>
> So basically, without searching but simply return all entries in the index
> with customized sorting as well. Can this be achieved?
>
>
> --
> View this message in context:
> http://www.nabble.com/Are-you-able-to-list-everything-in-index-tp22652917p22652917.html
> Sent from the Lucene - General mailing list archive at Nabble.com.
>
>