FAQ
The Lucene FAQ has a Q, "How do I retrieve all the values of a
particular field that exists within an index, across all documents?"
and gives some code. However, it looks like that code returns only
unique values. How does one get all values including duplicates?

- Paul

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

Search Discussions

  • Erick Erickson at Mar 19, 2009 at 5:26 pm
    See TermEnum/TermDocs.....
    On Thu, Mar 19, 2009 at 12:41 PM, Paul J. Lucas wrote:

    The Lucene FAQ has a Q, "How do I retrieve all the values of a particular
    field that exists within an index, across all documents?" and gives some
    code. However, it looks like that code returns only unique values. How
    does one get all values including duplicates?

    - Paul

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Paul J. Lucas at Mar 19, 2009 at 9:04 pm
    Uhm, a code snippet, perhaps?? Thanks.

    - Paul

    On Mar 19, 2009, at 10:26 AM, Erick Erickson wrote:

    See TermEnum/TermDocs.....
    On Thu, Mar 19, 2009 at 12:41 PM, Paul J. Lucas wrote:

    The Lucene FAQ has a Q, "How do I retrieve all the values of a
    particular
    field that exists within an index, across all documents?" and gives
    some
    code. However, it looks like that code returns only unique
    values. How
    does one get all values including duplicates?
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Paul J. Lucas at Mar 19, 2009 at 9:56 pm
    Actually, the code I had previously was:

    TermEnum e = reader.terms( new Term( fieldName, "" ) );
    Collection<String> values = new LinkedList<String>();
    while ( fieldName.equals( e.term().field() ) ) {
    String text = e.term().text();
    if ( text.length() > 0 )
    values.add( text );
    if ( !e.next() )
    break;
    }

    I think all I have to do is repeat the add() when docFreq() > 1 like:

    if ( text.length() > 0 )
    for ( int i = e.docFreq(); i > 0; --i )
    values.add( text );

    Right?

    - Paul

    On Mar 19, 2009, at 10:26 AM, Erick Erickson wrote:

    See TermEnum/TermDocs.....
    On Thu, Mar 19, 2009 at 12:41 PM, Paul J. Lucas wrote:

    The Lucene FAQ has a Q, "How do I retrieve all the values of a
    particular
    field that exists within an index, across all documents?" and gives
    some
    code. However, it looks like that code returns only unique
    values. How
    does one get all values including duplicates?
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMar 19, '09 at 4:41p
activeMar 19, '09 at 9:56p
posts4
users2
websitelucene.apache.org

2 users in discussion

Paul J. Lucas: 3 posts Erick Erickson: 1 post

People

Translate

site design / logo © 2022 Grokbase