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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:39:11+00:00 2026-05-14T01:39:11+00:00

I have this question relating to Lucene. I have a form and I get

  • 0

I have this question relating to Lucene.

I have a form and I get a text from it and I want to perform a full text search in several fields. Suppose I get from the input the text “textToLook”.

I have a Lucene Analyzer with several filters. One of them is lowerCaseFilter, so when I create the index, words will be lowercased.

Imagine I want to search into two fields field1 and field2 so the lucene query would be something like this (note that ‘textToLook’ now is ‘texttolook’):

field1: texttolook* field2:texttolook*

In my class I have something like this to create the query. I works when there is no wildcard.

String text = "textToLook";
String[] fields = {"field1", "field2"};
//analyser is the same as the one used for indexing
Analyzer analyzer = fullTextEntityManager.getSearchFactory().getAnalyzer("customAnalyzer");
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
org.apache.lucene.search.Query queryTextoLibre = parser.parse(text);

With this code the query would be:

field1: texttolook field2:texttolook

but If I set text to “textToLook*” I get

field1: textToLook* field2:textToLook*

which won’t find correctly as the indexes are in lowercase.

I have read in lucene website this:

” Wildcard, Prefix, and Fuzzy queries
are not passed through the Analyzer,
which is the component that performs
operations such as stemming and
lowercasing”

My problem cannot be solved by setting the behaviour case insensitive cause my analyzer has other fields which for examples remove some suffixes of words.

I think I can solve the problem by getting how the text would be after going through the filters of my analyzer, then I could add the “*” and then I could build the Query with MultiFieldQueryParser. So in this example I woud get “textToLower” and after being passed to to these filters I could get “texttolower”. After this I could make “textotolower*”.

But, is there any way to get the value of my text variable after going through all my analyzer’s filters? How can I get all the filters of my analyzer? Is this possible?

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-14T01:39:11+00:00Added an answer on May 14, 2026 at 1:39 am

    Can you use QueryParser.setLowercaseExpandedTerms(true)?

    http://wiki.apache.org/lucene-java/LuceneFAQ#Are_Wildcard.2C_Prefix.2C_and_Fuzzy_queries_case_sensitive.3F

    ** EDIT **

    Okay, I understand your issue now. You actually want the wildcarded term to be stemmed before it’s run through the wildcard query.

    You can subclass QueryParser and override

    protected Query getWildcardQuery(String field, String termStr) throws ParseException
    

    to run termStr through the analyzer before the WildcardQuery is constructed.

    This might not be what the user expects, though. There’s a reason why they’ve decided not to run wildcarded terms through the analyzer, per the faq:

    The reason for skipping the Analyzer
    is that if you were searching for
    “dogs*” you would not want “dogs”
    first stemmed to “dog”, since that
    would then match “dog*”, which is not
    the intended query.

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

Sidebar

Related Questions

I have this question: How could I call a codebehind method from jquery? I
I have a question relating to the usage of this. Suppose I have two
This is a follow on from my last question relating to plotting timestamps in
I'm aware of several question on this forum relating to this. But I'm not
I have a question relating to the answer on this post Javascript code to
Relating to this question, Upload files directly to Amazon S3 from ASP.NET application ,
Apologies for the essay-like nature of this question. I have been struggling to get
Somewhat related to this question and several other SO questions relating to formatting decimals
i have seen other blogs and SO questions relating to this issue but none
I have this question, just in theory. I do some query results and there

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.