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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:01:45+00:00 2026-05-23T12:01:45+00:00

I am using hibernate-search-3.2.1.Final and would like to parse my input into shingles. From

  • 0

I am using hibernate-search-3.2.1.Final and would like to parse my input into shingles. From what i can see in the documentation, ShingleAnalyzerWrapper seem to be exactly what I needed. I have tested with both WhitespaceAnalyzer, StandardAnalyzer, and SnowballAnalyzer as the default analyzer for the ShingleAnalyzerWrapper.

Version luceneVersion = Version.LUCENE_29;
SnowballAnalyzer keywordAnalyzer= new SnowballAnalyzer(luceneVersion, "English", StopAnalyzer.ENGLISH_STOP_WORDS_SET);
ShingleAnalyzerWrapper shingleAnalyzer = new ShingleAnalyzerWrapper(keywordAnalyzer, 4);
shingleAnalyzer.setOutputUnigrams(false);
QueryParser keywordParser = new QueryParser(luceneVersion, "keyword", keywordAnalyzer);
Query keywordQuery = keywordParser.parse(QueryParser.escape(keyword.toLowerCase()));

However, the query came back empty. I was expecting keyword like “hello world, this is Lucene” to result in shingles [hello world this is, world this is lucene, this is lucene]

Let me know if my expectation and usage of ShingleAnalyzerWrapper is correct.

Thanks,
Ryan

  • 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-23T12:01:46+00:00Added an answer on May 23, 2026 at 12:01 pm

    Maybe it’s a copy/paste error, but in your code snippet, the shingleAnalyzer is not actually being used because you’re passing the variable keywordAnalyzer to the query parser. What analyzer are you using at indexing time?

    If you use an analyzer that filters out stop words as the delegate analyzer for ShingleAnalyzerWrapper, stop words (“this” and “is” in your example) will be dropped before the shingle analyzer has a chance to create shingles from them.

    A good way to debug analyzers is to use something like AnalyzerUtils described in “Lucene in Action”. You can get the sample code here: http://java.codefetch.com/example/in/LuceneInAction/src/lia/analysis/AnalyzerUtils.java

    Nikita

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

Sidebar

Related Questions

I would like to ask if it's possible to do this using hibernate. Let
Using Hibernate how would you design and implement a search criteria page (which has
Using hibernate, how can I persist a class with a List<String> field? Consider the
when using hibernate with spring, can someone explain how the session unit of work
I'm using hibernate validators with JSF. How can I set my conversion error messages?
I'm currently moving a (working) app from using EclipseLink to Hibernate JPA, mostly it's
I am using Hibernate Search and applied Lucene indexing on one table for a
I'm using the hibernate generic dao project . I need to search for all
I'm using hibernate search 3.4, and I'm running in to a small problem. I
I'm using Hibernate in a project, and I have to search for Objects in

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.