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

The Archive Base Latest Questions

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

The title might be somewhat ambiguous, but bear with me (The only similar question

  • 0

The title might be somewhat ambiguous, but bear with me (The only similar question I could find was Solr: Search in multiple fields BUT STOP if documents match was found, but that did not provide any solutions). I have the following structure for my lucene documents:

FieldA (Store.YES, Index.ANALYZED), primary identification of an entity
FieldB (Store.YES, Index.ANALYZED), secondary identification(s) of an entity

FieldA could for example contain a string like car, where FieldB could contain strings like automobile, vehicle, etc. There can be multiple FieldB fields in the document. The index analyzer is a StandardAnalyzer, the search analyzer is a KeywordAnalyzer (that seemed to yield the best result, not sure if it is the best approach). The identifier in FieldA is of higher importance then the identifier(s) in FieldB.

Let’s say the index contains 3 documents (with FieldA | FieldB fields):

"car"       | "vehicle" "automobile"
"car parts" | "parts, car"
"car shop"  | "shop, car"

So far, so good. Now where the problem lies:

When querying for "car", I would like to see the following result (scores are made up):

car, score 1.0
car parts, score 0.9
car shop, score 0.9

The document with the FieldA value of “car” should show up first, since FieldA is considered more important, and the query matches that value best. In reality, the following happens:

car parts, score 0.625
car shop, score 0.625
car, score 0.5073969

searcher.explain() outputs the following: (left the explain for “car shop” out, since it is the same as “car parts”)

Explain: 0.625 = (MATCH) max of:
  0.31712303 = (MATCH) weight(fielda:car in 0), product of:
    0.71231794 = queryWeight(fielda:car), product of:
      0.71231794 = idf(docFreq=3, maxDocs=3)
      1.0 = queryNorm
    0.4451987 = (MATCH) fieldWeight(fielda:car in 0), product of:
      1.0 = tf(termFreq(fielda:car)=1)
      0.71231794 = idf(docFreq=3, maxDocs=3)
      0.625 = fieldNorm(field=fielda, doc=0)
  0.625 = (MATCH) fieldWeight(fieldb:car in 0), product of:
    1.0 = tf(termFreq(fieldb:car)=1)
    1.0 = idf(docFreq=2, maxDocs=3)
    0.625 = fieldNorm(field=fieldb, doc=0)
Explain: 0.5073969 = (MATCH) max of:
  0.5073969 = (MATCH) weight(fielda:car in 0), product of:
    0.71231794 = queryWeight(fielda:car), product of:
      0.71231794 = idf(docFreq=3, maxDocs=3)
      1.0 = queryNorm
    0.71231794 = (MATCH) fieldWeight(fielda:car in 0), product of:
      1.0 = tf(termFreq(fielda:car)=1)
      0.71231794 = idf(docFreq=3, maxDocs=3)
      1.0 = fieldNorm(field=fielda, doc=0)

TL;DR: with the two fields, boosting FieldA will not help because all 3 documents will get boosted. How to get lucene to rank the closest match (“car” in this example”) as the highest? i.e. how to stop searching in the current document after the (more important) match in FieldA is encountered?

  • 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-28T00:24:03+00:00Added an answer on May 28, 2026 at 12:24 am

    Use NOT syntax.

    a:car^2 (+b:car -a:car)

    This way ones with matches in b will be ignored unless they fail to match a.

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

Sidebar

Related Questions

The title of this question might be a bit off but its the closest
the title might be too generic, but I have a very specific question about
the question title might be a bit confuse. but here is my case. i
The title might sound convoluted but bear with me. I have Rooms which contain
Probably question title might looks strange for you, but I'll try to explain. I
The title might been misleading, but I can´t pack my question in one sentence.
Question title might be meaningless, but I tried. :) Here's my situation: I have
The title might not explain my problem fully but I wasn't sure how to
I asked a question , title of which might have been misleading so I'm
Apologies for the long winded title but looking for a solution to what might

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.