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 Phil Whelan <ph...@gmail.com> on 2009/08/01 02:15:26 UTC

Is it possible to retrieve Terms from a Document?

Hi,

I know you can use Field.Store.YES, but I want to inspect the terms /
tokens and their order related to the field name at search time. Is
this possible? Obviously this information is stored in the index, but
I can not find any API to access it. I'm guessing the answer might be
that Terms point to a Document and not the other way around. Is this
right?

eg.
Document doc = .... ;
Term[] terms = doc.getTerms();

Or...
String[] values = doc.getTermValues();

Thanks,
Phil

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


Re: Is it possible to retrieve Terms from a Document?

Posted by Grant Ingersoll <gs...@apache.org>.
See the Term Vector capability. http://www.lucidimagination.com/search/?q=term+vectors#/ 
p:lucene

By default the information is _not_ stored in the index.  You will  
need to add Field.TermVector.YES to your indexing in order for this  
information to be available.

-Grant

On Jul 31, 2009, at 8:15 PM, Phil Whelan wrote:

> Hi,
>
> I know you can use Field.Store.YES, but I want to inspect the terms /
> tokens and their order related to the field name at search time. Is
> this possible? Obviously this information is stored in the index, but
> I can not find any API to access it. I'm guessing the answer might be
> that Terms point to a Document and not the other way around. Is this
> right?
>
> eg.
> Document doc = .... ;
> Term[] terms = doc.getTerms();
>
> Or...
> String[] values = doc.getTermValues();
>
> Thanks,
> Phil
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids)  
using Solr/Lucene:
http://www.lucidimagination.com/search


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