Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:01:24+00:00 2026-05-28T13:01:24+00:00

I have an index from a large corpus with several fields. Only one these

  • 0

I have an index from a large corpus with several fields. Only one these fields contain text.
I need to extract the unique words from the whole index based on this field.
Does anyone know how I can do that with Lucene in java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:01:25+00:00Added an answer on May 28, 2026 at 1:01 pm

    You’re looking for term vectors (a set of all the words that were in the field and the number of times each word was used, excluding stop words). You’ll use IndexReader’s getTermFreqVector(docid, field) for each document in the index, and populate a HashSet with them.

    The alternative would be to use terms() and pick only terms for the field you’re interested in:

    IndexReader reader = IndexReader.open(index);
    TermEnum terms = reader.terms();
    Set<String> uniqueTerms = new HashSet<String>();
    while (terms.next()) {
            final Term term = terms.term();
            if (term.field().equals("field_name")) {
                    uniqueTerms.add(term.text());
            }
    }
    

    This is not the optimal solution, you’re reading and then discarding all other fields. There’s a class Fields in Lucene 4, that returns terms(field) only for a single field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large index of files. One of the fields I have is
I have: $page_file_temp = $_SERVER[PHP_SELF]; which will output: /templates/somename/index.php I want to extract from
I Have website I need to save a large amount of pages from. The
I have many large (>35,000,000) lists of integers that will contain duplicates. I need
i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
How to continue from where I have been searching to find the index? I
I have a large matrix from which I would like to gather a collection
I have a large index, on which Highlighter.Net works fine, but FastVectorHighlighter returns null
I have a large nested array that I'm generating from parsing a CSV file
I have a pretty large table (20M records) which has a 3 column index

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.