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

Mailing List Archive: Lucene: General

Are you able to list everything in index

 

 

Lucene general RSS feed   Index | Next | Previous | View Threaded


rockacola at gmail

Mar 22, 2009, 6:15 PM

Post #1 of 5 (1082 views)
Permalink
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.


evert.wagenaar at gmail

Mar 23, 2009, 1:40 AM

Post #2 of 5 (994 views)
Permalink
Re: Are you able to list everything in index [In reply to]

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 <rockacola [at] gmail> 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.
>
>


rockacola at gmail

Mar 23, 2009, 3:48 PM

Post #3 of 5 (991 views)
Permalink
Re: Are you able to list everything in index [In reply to]

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.


ted.dunning at gmail

Mar 23, 2009, 4:01 PM

Post #4 of 5 (987 views)
Permalink
Re: Are you able to list everything in index [In reply to]

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 <rockacola [at] gmail> 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;
> }
>
>
>


rockacola at gmail

Mar 23, 2009, 4:07 PM

Post #5 of 5 (997 views)
Permalink
Re: Are you able to list everything in index [In reply to]

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.

Lucene general 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.