Re: How to loop through all the entries for a field

2009年10月23日 02:05:48 -0700

You can use "Lucene.Net.Index.TermDocs tDocs = reader.TermDocs(term)" in
your loop.
DIGY
PS: Another Question: How many pages does the book "T1" have?
Title : T1
Author : A1
#ofPages : 100
Publisher: P1
Title : T1
Author : A2
#ofPages : 200
Publisher: P1
Title : T1
Author : A1
#ofPages : 102
Publisher: P2
On Fri, Oct 23, 2009 at 3:11 AM, Eric Advincula <
[email protected]> wrote:
> Question, now that i'm looping through the BookTitle, how can i also get
> the PageCount field that is part of the document. So every BookTitle has a
> PageCount to signify the total number of pages per book.
> Thanks
>
>
>
> reader = IndexReader.Open(Commons.Constants._FSDirectory);
> termEnum = reader.Terms(new Term("BookTitle", ""));
>
>
> while ((term = termEnum.Term()) != null)
> {
> if (!term.Field().Equals("BookTitle"))
> break;
>
> map = new SearchResultMap();
> map.Title = term.Text();
>
> control.Items.Add(map);
>
> termEnum.Next();
> }
>
>
> >>>
>
> From: "Eric Advincula" <[email protected]>
> To:<[email protected]>
> Date: 10/22/2009 2:29 PM
> Subject: RE: How to loop through all the entries for a field
> nevermind I figured it out. I did this:
>
> while ((term = termEnum.Term()) != null)
> {
> if (!term.Field().Equals("BookTitle"))
> break;
>
> map = new SearchResultMap();
> map.Title = term.Text();
>
> control.Items.Add(map);
>
> termEnum.Next();
> }
>
> thanks for all the help
>
>
> >>>
>
> From: "Eric Advincula" <[email protected]>
> To:<[email protected]>
> Date: 10/22/2009 2:22 PM
> Subject: RE: How to loop through all the entries for a field
> It works but continues even after the listing.
> How do you know if your on your last term? I tried it and it does work but
> continues. How do you know to check if its the last entry?
>
> Thanks
>
> >>>
>
> From: "Digy" <[email protected]>
> To:<[email protected]>
> Date: 10/22/2009 12:13 PM
> Subject: RE: How to loop through all the entries for a field
> Something like that?
>
>
>
> Lucene.Net.Index.IndexReader reader =
> Lucene.Net.Index.IndexReader.Open(dir);
>
> Lucene.Net.Index.TermEnum tEnum = reader.Terms(new
> Lucene.Net.Index.Term("BookTitle"));
>
> do
>
> {
>
> Lucene.Net.Index.Term t = tEnum.Term();
>
> Console.WriteLine(t.Text());
>
> } while (tEnum.Next());
>
>
>
> DIGY
>
>
>
> -----Original Message-----
> From: Eric Advincula [mailto:[email protected]]
> Sent: Thursday, October 22, 2009 6:51 PM
> To: [email protected]
> Subject: How to loop through all the entries for a field
>
>
>
> I have a field in called BookTitle. I want to loop through all the entries
> without doing a search. I just want to get the list of BookTitle's that is
> in this field:
>
>
>
> I tried IndexReader but MaxDocs() doesnt work because it returns everything
> and I have other fields in their which is allot bigger.
>
>
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>
> !DSPAM:4ae0cd83644852014519530!
>

Reply via email to