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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:20:32+00:00 2026-06-11T01:20:32+00:00

I have the fields title and keyword in my Lucene (3.6) documents. When I

  • 0

I have the fields “title” and “keyword” in my Lucene (3.6) documents. When I have an object with title=Testfair 2012-09 and a keyword of someTest, I write the document like:

Document doc = new Document();
doc.add(new Field("title", title, Field.Store.NO, Field.Index.ANALYZED));
doc.add(new Field("keyword", keyword, Field.Store.NO, Field.Index.ANALYZED));

For searching I use

QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_36, new String[] { "title", "keyword" }, new StandardAnalyzer(Version.LUCENE_36));
queryParser.setDefaultOperator(QueryParser.AND_OPERATOR);
queryParser.setAllowLeadingWildcard(true);
Query query = queryParser.parse(queryString);

IndexSearcher searcher = createSearcher();
TopScoreDocCollector collector = TopScoreDocCollector.create(1000, true);
searcher.search(query, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;

In the index, I can see (via Luke) that the field title in the index has the values "Testfair", "2012" and "09".

Now I’d like the following behaviour when searching:

Testfair 2012-09 -> match     (1)
estfair          -> match     (2)
Testfair baz     -> no match  (3)

I am not sure how to handle this because I need the implicit wildcard search for case (2). If I split the search term at whitespaces and add * before and after every word, I get the search for +(title:*testmesse*) +(title:*2012-09*), so the 2012-09 is not split and no result is found. If I understand correctly the problem lies within the usage of the MultiFieldQueryParser but I don’t know how I would set up the search correctly or if I should somehow modify the indexing process.

Any help appreciated! 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-06-11T01:20:33+00:00Added an answer on June 11, 2026 at 1:20 am

    In the meantime, I got the book “Lucene in Action” and took the advice from there: Create a “catch all” field which contains all searchable fields within one field and search that field only. With the help of this trick I can skip the MultiFieldQueryParser because I only have one field to search in. Now I can simply analyze the search term and modify it the way I need it.

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

Sidebar

Related Questions

I have an indexed object with three fields (userId, title, description). I want to
I have the following code to create the Zend Lucene index $doc->addField(Zend_Search_Lucene_Field::UnStored('keywords', $job->getKeywords())); $doc->addField(Zend_Search_Lucene_Field::UnStored('title',
I have a list, that has three fields: Title, PublishingRollupImage and Description. I want
I have form like this : <div id='add_field' class='locbutton'><a href='#' title='Add'>Add</a></div> <div id='remove_field' class='locbutton2'><a
I have fields in the column that look like so: 2/8B, 3, 3/8B, 4/8B,
I have some documents in couchdb that have fields that are arrays of id's
i have two fields: title body and i want to search for two words
We store documents that look something like this: { id: dQesbpxeQniUWXpsnjPQ, title: Golf in
Let's say I have a domain object that looks like this: @Entity @Indexed public
I have title (varchar), description (text), keywords (varchar) fields in my mysql table. I

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.