You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Dragon Fly <dr...@hotmail.com> on 2008/03/20 14:55:01 UTC
Field values ...
What's the easiest way to extract the values of 2 fields from each document in the index. For example, each document has 5 fields:
Id Name Address Phone Preference
I'd like to extract the values for the Id and Phone fields for each document in the index. Thank you.
_________________________________________________________________
Watch “Cause Effect,” a show about real people making a real difference. Learn more.
http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
RE: Field values ...
Posted by Dragon Fly <dr...@hotmail.com>.
Thanks.
> Date: Mon, 24 Mar 2008 21:03:13 -0700
> From: hossman_lucene@fucit.org
> To: java-user@lucene.apache.org
> Subject: RE: Field values ...
>
>
> : The Id and Phone fields are stored. So I can just do a MatchAllQuery as
> : you suggested. I have read about field selectors on this mailing list
> : but have never used it. Does anyone know where I can find some sample
> : code? Thank you.
>
> there's a couple of reusable implementations in subversion...
>
> http://www.krugle.org/kse/files?query=%22implements%20FieldSelector%22%20lucene&lang=java&findin=code
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
_________________________________________________________________
Watch “Cause Effect,” a show about real people making a real difference. Learn more.
http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
RE: Field values ...
Posted by Chris Hostetter <ho...@fucit.org>.
: The Id and Phone fields are stored. So I can just do a MatchAllQuery as
: you suggested. I have read about field selectors on this mailing list
: but have never used it. Does anyone know where I can find some sample
: code? Thank you.
there's a couple of reusable implementations in subversion...
http://www.krugle.org/kse/files?query=%22implements%20FieldSelector%22%20lucene&lang=java&findin=code
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Field values ...
Posted by Dragon Fly <dr...@hotmail.com>.
The Id and Phone fields are stored. So I can just do a MatchAllQuery as you suggested. I have read about field selectors on this mailing list but have never used it. Does anyone know where I can find some sample code? Thank you.
> Date: Sat, 22 Mar 2008 16:03:54 -0700
> From: hossman_lucene@fucit.org
> To: java-user@lucene.apache.org
> Subject: RE: Field values ...
>
>
> : I want to do something like:
> :
> : List<Info> infoList = new ArrayList<Info> ();
> : foreach (Document doc in LuceneIndex)
> : {
> : String id = doc.get ("Id");
> : String phone = doc.get ("Phone");
> : infoList.add (new Info (id, phone));
> : }
>
> If "Id" and "Phone" are stored values then that code will pretty much work
> as is ... jut change "Document doc in LuceneIndex" to be something that
> does a MtchAllQuery (putting your code in a HitCollector would probably be
> pretty straight forward.
>
> But it won't neccessarily be very efficient, particularly if you've got a
> lot of other stored fields, but a FieldSelector can help make it faster.
>
> if Id and Phone are both indexed fields, and ever doc has only one value
> for each then you can use the FieldCache to get an array for each of them,
> and then just iterate over the arrays in parallel (watch out for deleted
> documents)
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
_________________________________________________________________
Test your Star IQ
http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_HMTAGMAR
RE: Field values ...
Posted by Chris Hostetter <ho...@fucit.org>.
: I want to do something like:
:
: List<Info> infoList = new ArrayList<Info> ();
: foreach (Document doc in LuceneIndex)
: {
: String id = doc.get ("Id");
: String phone = doc.get ("Phone");
: infoList.add (new Info (id, phone));
: }
If "Id" and "Phone" are stored values then that code will pretty much work
as is ... jut change "Document doc in LuceneIndex" to be something that
does a MtchAllQuery (putting your code in a HitCollector would probably be
pretty straight forward.
But it won't neccessarily be very efficient, particularly if you've got a
lot of other stored fields, but a FieldSelector can help make it faster.
if Id and Phone are both indexed fields, and ever doc has only one value
for each then you can use the FieldCache to get an array for each of them,
and then just iterate over the arrays in parallel (watch out for deleted
documents)
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Field values ...
Posted by Dragon Fly <dr...@hotmail.com>.
I was able to get a list of all the values for the Id field and another list of all the values for the Phone field using TermEnum (i.e. two independent lists). However, what I really wanted was:
- Get the first Id
- Get the Phone associated with the first Id.
- Get the second Id
- Get the Phone associated with the second Id.
...
...
I want to do something like:
List<Info> infoList = new ArrayList<Info> ();
foreach (Document doc in LuceneIndex)
{
String id = doc.get ("Id");
String phone = doc.get ("Phone");
infoList.add (new Info (id, phone));
}
Thank you.
> Date: Thu, 20 Mar 2008 10:05:17 -0400
> From: erickerickson@gmail.com
> To: java-user@lucene.apache.org
> Subject: Re: Field values ...
>
> See TermDocs/TermEnum. The trick is to start one of your enumerations
> with "" (I forget exactly which), and that'll iterate them all.
>
> Best
> Erick
>
> On Thu, Mar 20, 2008 at 9:55 AM, Dragon Fly <dr...@hotmail.com>
> wrote:
>
> > What's the easiest way to extract the values of 2 fields from each
> > document in the index. For example, each document has 5 fields:
> > Id Name Address Phone Preference
> > I'd like to extract the values for the Id and Phone fields for each
> > document in the index. Thank you.
> >
> > _________________________________________________________________
> > Watch "Cause Effect," a show about real people making a real difference.
> > Learn more.
> > http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
_________________________________________________________________
How well do you know your celebrity gossip?
http://originals.msn.com/thebigdebate?ocid=T002MSN03N0707A
RE: Field values ...
Posted by Dragon Fly <dr...@hotmail.com>.
I was able to get a list of all the values for the Id field and another list of all the values for the Phone field using TermEnum (i.e. two independent lists). However, what I really wanted was:
- Get the first Id
- Get the Phone associated with the first Id.
- Get the second Id
- Get the Phone associated with the second Id.
...
...
I want to do something like:
List<Info> infoList = new ArrayList<Info> ();
foreach (Document doc in LuceneIndex)
{
String id = doc.get ("Id");
String phone = doc.get ("Phone");
infoList.add (new Info (id, phone));
}
Thank you.
> Date: Thu, 20 Mar 2008 10:05:17 -0400
> From: erickerickson@gmail.com
> To: java-user@lucene.apache.org
> Subject: Re: Field values ...
>
> See TermDocs/TermEnum. The trick is to start one of your enumerations
> with "" (I forget exactly which), and that'll iterate them all.
>
> Best
> Erick
>
> On Thu, Mar 20, 2008 at 9:55 AM, Dragon Fly <dr...@hotmail.com>
> wrote:
>
> > What's the easiest way to extract the values of 2 fields from each
> > document in the index. For example, each document has 5 fields:
> > Id Name Address Phone Preference
> > I'd like to extract the values for the Id and Phone fields for each
> > document in the index. Thank you.
> >
> > _________________________________________________________________
> > Watch "Cause Effect," a show about real people making a real difference.
> > Learn more.
> > http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
_________________________________________________________________
Test your Star IQ
http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_HMTAGMAR
Re: Field values ...
Posted by Erick Erickson <er...@gmail.com>.
See TermDocs/TermEnum. The trick is to start one of your enumerations
with "" (I forget exactly which), and that'll iterate them all.
Best
Erick
On Thu, Mar 20, 2008 at 9:55 AM, Dragon Fly <dr...@hotmail.com>
wrote:
> What's the easiest way to extract the values of 2 fields from each
> document in the index. For example, each document has 5 fields:
> Id Name Address Phone Preference
> I'd like to extract the values for the Id and Phone fields for each
> document in the index. Thank you.
>
> _________________________________________________________________
> Watch "Cause Effect," a show about real people making a real difference.
> Learn more.
> http://im.live.com/Messenger/IM/MTV/?source=text_watchcause