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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:01:33+00:00 2026-05-12T09:01:33+00:00

What is the best way to handle synonyms (phrases) using Lucene? Especially, when I

  • 0

What is the best way to handle synonyms (phrases) using Lucene?
Especially, when I need to execute queries like :a OR b OR c NOT d

How about adding a new field called “synonyms” to each document while indexing?
This field’s value would have a list of all synonyms. It would be added to a document only when that document has any of the synonyms.

I would then execute an “OR” search query which would look for search keyword in this field along with other fields.

Can this approach work well for any kind of query?

FYI,
The synonyms in my application are totally custom and not from English dictionary…ie. “Global Leader in Finance” could also mean “Top Investment Bank” or “Fortune 500 Finance company” etc etc.

Please suggest.

Thanks.

  • 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-12T09:01:33+00:00Added an answer on May 12, 2026 at 9:01 am

    There is a contribution to the Lucene project called “wordnet”. According to its documentation:

    This package uses synonyms defined by WordNet to build a Lucene index storing them, which in turn can be used for query expansion. You normally run Syns2Index once to build the query index/”database”, and then call SynExpand.expand(…) to expand a query.

    It includes a sample of what it does:

    If you pass in the query “big dog” then it prints out:

    Query: big adult^0.9 bad^0.9 bighearted^0.9 boastful^0.9 boastfully^0.9 bounteous^0.9 bountiful^0.9 braggy^0.9 crowing^0.9 freehanded^0.9 giving^0.9 grown^0.9 grownup^0.9 handsome^0.9 large^0.9 liberal^0.9 magnanimous^0.9 momentous^0.9 openhanded^0.9 prominent^0.9 swelled^0.9 vainglorious^0.9 vauntingly^0.9
    dog andiron^0.9 blackguard^0.9 bounder^0.9 cad^0.9 chase^0.9 click^0.9 detent^0.9 dogtooth^0.9 firedog^0.9 frank^0.9 frankfurter^0.9 frump^0.9 heel^0.9 hotdog^0.9 hound^0.9 pawl^0.9 tag^0.9 tail^0.9 track^0.9 trail^0.9 weenie^0.9 wiener^0.9 wienerwurst^0.9

    You see that the original words (“big” and “dog”) have no weighting attached to them. The synonyms, however, have a weighting (0.9) that you can configure yourself.

    It comes bundled with the standard distribution of Lucene, in the “contrib” directory.

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

Sidebar

Related Questions

What is the best way to handle RejectedExecutionException while using a ThreadPoolExecutor in Java?
What is the best way to handle the following database search scenario using asp.net
What's the best way to handle adding a new (optional) parameter to an existing
Can someone explain the best way to handle this approach. I am using TinyMCE
I'd like to know the correct / best way to handle concurrency with an
What is the best way to handle resources (like images, files, ...) in vala?
I would like to know the best way to handle and implement session time
What's the best way to handle something like this: Razor Code: @if(!disableRowDiv) { <div
Not sure if this is the best way to handle this, but I had
What is the best way to handle the need to a user to download

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.