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 8957951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:06:45+00:00 2026-06-15T15:06:45+00:00

I am using Lucene 3.6.1. I have a BooleanQuery some clauses of which are

  • 0

I am using Lucene 3.6.1. I have a BooleanQuery some clauses of which are marked as Occur.MUST_NOT. When I extract terms from this query, it happily extracts the terms that must not occur as well. This is so because of the following code in BooleanQuery.java

  @Override
  public void extractTerms(Set<Term> terms) {
      for (BooleanClause clause : clauses) {
          clause.getQuery().extractTerms(terms);
      }
  }

I am using these terms to present the user with a set of terms that can be added or removed from the query. If the user has explicitly specified that some term or phrase is not desired (e..g, by adding -"foo bar" to a query), I don’t want to show these terms to him. What might make more sense is code like this:

  @Override
  public void extractTerms(Set<Term> terms) {
      for (BooleanClause clause : clauses) {
          if (!clause.isProhibited())
              clause.getQuery().extractTerms(terms);
      }
  }

What is the design rationale for the existing implementation? When does it make sense? What’s the best way to get around this problem, assuming I don’t want negated terms, but don’t know where in the query tree they occur?

  • 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-06-15T15:06:46+00:00Added an answer on June 15, 2026 at 3:06 pm

    Gene: maybe you can open a LUCENE Jira ticket for this?

    I actually think extractTerms should do as you suggest. For example if i make a simple highlighter that uses this method (which I’ve done before), I don’t want the negative portions either. I’m guessing in general this is the expected behavior for most uses of this method.

    At the very least its currently inconsistent, e.g. SpanNotQuery is in the same boat and excludes its “negative” portions from extractTerms.

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

Sidebar

Related Questions

I have a site which is searchable using Lucene. I've noticed from logs that
I have some code using Lucene that leaves the default conjunction operator as OR,
I'm using Zend_Search_Lucene, the PHP port of Java Lucene. I currently have some code
Normally when using Lucene you set a search query and Lucene gives you some
I have news-article content which is being indexes using Lucene and interrogated using Zend_Lucene
Am using Lucene API in my web portal which is going to have 1000s
I have a single XML file that I want to index using Lucene.NET. The
I am looking into using Lucene.NET after reading some bad reviews of SQL Server's
Let's say we have a Lucene index having few documents indexed using StopAnalyzer.ENGLISH_STOP_WORDS_SET .
I'm trying to make a searchable phone/local business directory using Apache Lucene. I have

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.