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

  • Home
  • SEARCH
  • 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 1090945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:26:54+00:00 2026-05-16T23:26:54+00:00

Using Hibernate Search Annotations (mostly just @Field(index = Index.TOKENIZED) ) I’ve indexed a number

  • 0

Using Hibernate Search Annotations (mostly just @Field(index = Index.TOKENIZED)) I’ve indexed a number of fields related to a persisted class of mine called Compound. I’ve setup text search over all the indexed fields, using the MultiFieldQueryParser, which has so far worked fine.

Among the fields indexed and searchable is a field called compoundName, with sample values:

  • 3-Hydroxyflavone
  • 6,4'-Dihydroxyflavone

When I search for either of these values in full the related Compound instances are returned. However problems occur when I use the partial name and introduce wildcards:

  • searching for 3-Hydroxyflav* still gives the correct hit, but
  • searching for 6,4'-Dihydroxyflav* fails to find anything.

Now as I’m quite new to Lucene / Hibernate-search, I’m not quite sure where to look at this point.. I think it might have something to do with the ' present in the second query, but I don’t know how to proceed.. Should I look into Tokenizers / Analyzers / QueryParsers or something else entirely?

Or can anyone tell me how I can get the second wildcard search to match, preferably without breaking the MultiField-search behavior?

I’m using Hibernate-Search 3.1.0.GA & Lucene-core 2.9.3.


Some relevant code bits to illustrate my current approach:

Relevant parts of the indexed Compound class:

@Entity
@Indexed
@Data
@EqualsAndHashCode(callSuper = false, of = { "inchikey" })
public class Compound extends DomainObject {
    @NaturalId
    @NotEmpty
    @Length(max = 30)
    @Field(index = Index.TOKENIZED)
    private String                  inchikey;

    @ManyToOne
    @IndexedEmbedded
    private ChemicalClass           chemicalClass;

    @Field(index = Index.TOKENIZED)
    private String                  commonName;
...
}

How I currently search over the indexed fields:

String[] searchfields = Compound.getSearchfields();
MultiFieldQueryParser parser = 
    new MultiFieldQueryParser(Version.LUCENE_29, searchfields, new StandardAnalyzer(Version.LUCENE_29));
FullTextSession fullTextSession = Search.getFullTextSession(getSession());
FullTextQuery fullTextQuery = 
    fullTextSession.createFullTextQuery(parser.parse("searchterms"), Compound.class);
List<Compound> hits = fullTextQuery.list();
  • 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-16T23:26:55+00:00Added an answer on May 16, 2026 at 11:26 pm

    I think your problem is a combination of analyzer and query language problems. It is hard to say what exactly causes the problem. To find this out I recommend you inspect you index using the Lucene index tool Luke.

    Since in your Hibernate Search configuration you are not using a custom analyzer the default – StandardAnalyzer – is used. This would be consistent with the fact that you use StandardAnalyzer in the constructor of MultiFieldQueryParser (always use the same analyzer for indexing and searching!). What I am not so sure of is how “6,4′-Dihydroxyflavone” gets tokenized by StandardAnalyzer. That the first thing you have to find out. For example the javadoc says:

    Splits words at hyphens, unless
    there’s a number in the token, in
    which case the whole token is
    interpreted as a product number and is
    not split.

    It might be that you need to write your own analyzer which tokenizes your chemical names the way you need it for your use cases.

    Next the query parser. Make sure you understand the query syntax – Lucene query syntax. Some characters have special meaning, for example a ‘-‘. It could be that your query is parsed the wrong way.

    Either way, first step os to find out how your chemical names get tokenized. Hope that helps.

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

Sidebar

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.