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

The Archive Base Latest Questions

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

I have written a following code in my project: final IndexSearcher indexSearcher = new

  • 0

I have written a following code in my project:

final IndexSearcher indexSearcher = new IndexSearcher(INDEXING_DIRECTORY, true);  
final Query query = new QueryParser(Version.LUCENE_33, "keywords", new StandardAnalyzer(Version.LUCENE_33)).parse("cats movies");
final TopScoreDocCollector collector = TopScoreDocCollector.create(10, true);
indexSearcher.search(query, collector);
final ScoreDoc[] hits = collector.topDocs(0, 10).scoreDocs;

The task is very trivial.

I, for example, have a stored record with an indexed “keywords” field. The keywords for example might be similar to “Tons of movies with a funny cats”.

The problem is that my code above will return records if search query will be “funny cats” (word order like in the indexed field), but will fail on “cats movies”. How should I write my query, so it would match any words order, and if is possible searching for a similar words also?

  • 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-24T11:05:12+00:00Added an answer on May 24, 2026 at 11:05 am

    Most likely “cats movies” will be parsed as PhraseQuery. PhraseQueries respect ordering. What you want is to have a BooleanQuery with two TermQueries combined with AND.

    final Query query = new QueryParser(Version.LUCENE_33, "keywords", new StandardAnalyzer(Version.LUCENE_33)).parse("+cats AND +movies");
    

    Some more examples are listed here. Some may be already outdated.

    Similar words is a rather hard task because you need to have at least some sort of wordlist or database which aligns synonyms.

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

Sidebar

Related Questions

I have written the following code in my .net project. I've never used the
I have written the following code for my project. The code is scattered across
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
I have written a following code to get just the file name without extension
I have written the following code choice /m Do you want to add another
I have written the following code. But it is removing only &nbsp; not <br>
i have written the following code: As you can see there is a for
I have written the following code in Perl. I want to iterate through a
I have written the following IronPython code: import clr clr.AddReference(System.Drawing) from System import *

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.