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 Riccardo Daviddi <rd...@gmail.com> on 2005/09/10 18:44:50 UTC

How to get a list of field names of one doc?

Hy all,

I need to get a list of pair names-values (in two vector) of each fields a 
doc has, without knowing the names of the fields (an user can call fields as 
he wants).
Once I get the document by hits.doc(), Document has only a method fields() 
to get an enumeration, but it's not what I want (it's not only the names of 
the fields, it's names and values of the fields all together).
By now I am getting all the fields of an index by the 
IndexReader.getFieldNames() method and then manually testing if the document 
has each field. There is another way to know directly from a document all 
the field names the doc has?

thx
-- 
Riccardo Daviddi
University of Siena - Information Engeneering
rdaviddi@gmail.com

Re: How to get a list of field names of one doc?

Posted by Riccardo Daviddi <rd...@gmail.com>.
No Erik, thx to you!

I am sorry, I didn't understand that the enumeration was od Field type.
Now all it works.

Thank you again!

On 9/11/05, Erik Hatcher <er...@ehatchersolutions.com> wrote:
> 
> Riccardo,
> 
> I'm not quite understanding the issue with using Document.fields().
> It returns an Enumeration of Field objects, which contain the name
> and the value. If you only want the name, then only use the name and
> ignore the value. That seems simple enough, so I must be missing
> what you're asking for. Please clarify a bit more.
> 
> Thanks,
> Erik
> 
> 
> On Sep 10, 2005, at 12:44 PM, Riccardo Daviddi wrote:
> 
> > Hy all,
> >
> > I need to get a list of pair names-values (in two vector) of each
> > fields a
> > doc has, without knowing the names of the fields (an user can call
> > fields as
> > he wants).
> > Once I get the document by hits.doc(), Document has only a method
> > fields()
> > to get an enumeration, but it's not what I want (it's not only the
> > names of
> > the fields, it's names and values of the fields all together).
> > By now I am getting all the fields of an index by the
> > IndexReader.getFieldNames() method and then manually testing if the
> > document
> > has each field. There is another way to know directly from a
> > document all
> > the field names the doc has?
> >
> > thx
> > --
> > Riccardo Daviddi
> > University of Siena - Information Engeneering
> > rdaviddi@gmail.com
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 


-- 
Riccardo Daviddi
University of Siena - Information Engeneering
rdaviddi@gmail.com

Re: How to get a list of field names of one doc?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Riccardo,

I'm not quite understanding the issue with using Document.fields().   
It returns an Enumeration of Field objects, which contain the name  
and the value.  If you only want the name, then only use the name and  
ignore the value.  That seems simple enough, so I must be missing  
what you're asking for.  Please clarify a bit more.

Thanks,
     Erik


On Sep 10, 2005, at 12:44 PM, Riccardo Daviddi wrote:

> Hy all,
>
> I need to get a list of pair names-values (in two vector) of each  
> fields a
> doc has, without knowing the names of the fields (an user can call  
> fields as
> he wants).
> Once I get the document by hits.doc(), Document has only a method  
> fields()
> to get an enumeration, but it's not what I want (it's not only the  
> names of
> the fields, it's names and values of the fields all together).
> By now I am getting all the fields of an index by the
> IndexReader.getFieldNames() method and then manually testing if the  
> document
> has each field. There is another way to know directly from a  
> document all
> the field names the doc has?
>
> thx
> -- 
> Riccardo Daviddi
> University of Siena - Information Engeneering
> rdaviddi@gmail.com
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org