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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:12:30+00:00 2026-05-24T20:12:30+00:00

In Lucene.Net, I need to create a query to limit a search to a

  • 0

In Lucene.Net, I need to create a query to limit a search to a specific list of terms for a specific field.

For example, I need “AutoMake” to be “Ford” or “Chevy.” So, as long as the value of “AutoMake” is one of those two, we’re good.

Here’s how I’m forming my BooleanQuery, but I don’t think this is right:

var query1 = new TermQuery(new Term("AutoMake", "Ford"));
var query2 = new TermQuery(new Term("AutoMake", "Chevy"));

var thisFilter = new BooleanQuery();
thisFilter.Add(query1, BooleanClause.Occur.MUST);
thisFilter.Add(query2, BooleanClause.Occur.MUST);

The “MUST” there effectively “ANDs” the query, so “AutoMake” has to be both “Ford” and “Chevy,” which is wrong. (I’ve done some reading on the BooleanClause “SHOULD,” but I don’t think that’s right either.)

Essentially, I need a BooleanClause operator for “OR.” I need a way to encapsulate two queries so that if one of them is true, then the entire query is true? (Because, I have multiple of these queries feeding into a larger query as clauses.)

Here’s what would be awesome.

var query = new AnyOfTheseTermsQuery();
query.Add(new Term("AutoMake", "Ford"));
query.Add(new Term("AutoMake", "Chevy"));

That’s what I’m looking for. Does this exist?

  • 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-24T20:12:30+00:00Added an answer on May 24, 2026 at 8:12 pm

    I think “SHOULD” is the correct operator for this type of query. It’s probably worth your while setting up a small index to test this, but when I look at the documentation, it seems to be exactly what you’re after.

    Good luck,

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

Sidebar

Related Questions

I need to search through lucene.net document contains spaces between letters. example Document 1:
I want to search a Lucene.net index for a stored url field. My code
Good afternoon, I need to be able to search a Lucene.Net index with a
I have multiple lucene.net indexes that I would need to search on for a
I am using Lucene.NET and getting search results sorted by 'Date' field. Here are
I need to serialize a Lucene.net Document instance. When I try the following public
I'm using Lucene.Net to implement a search website (to search PDFs). Once the keyword
Currently I'm prototyping search with Lucene.Net-2.0-004 on a web application. It's working very well,
I'm trying using NHibernate.Search to get Lucene.NET Score through projections. My domain object implements
i created a project to search textfiles with lucene.net. [asp.net/vs08] these textfiles are in

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.