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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:58:01+00:00 2026-06-04T07:58:01+00:00

@AnalyzerDef( name = tags, tokenizer = @TokenizerDef(factory = PatternTokenizerFactory.class, params = { @Parameter(name =

  • 0
@AnalyzerDef(
        name = "tags",
        tokenizer = 
            @TokenizerDef(factory = PatternTokenizerFactory.class, 
                params = {
                    @Parameter(name = "pattern", value=",")
                }
            ),
        filters = {
            @TokenFilterDef(factory = StandardFilterFactory.class),
            @TokenFilterDef(factory = LowerCaseFilterFactory.class),
            @TokenFilterDef(
                factory = StopFilterFactory.class,
                params = {
                    @Parameter(name = "words", value = "data/ignorewords.txt"),
                    @Parameter(name = "ignoreCase", value = "true")
                }
            ),
            @TokenFilterDef(
                factory = SynonymFilterFactory.class,
                params = {
                    @Parameter(name = "ignoreCase", value="true"),
                    @Parameter(name = "expand", value="false"),
                    @Parameter(name = "synonyms", value="data/synonyms.txt")
                }
            ),
            @TokenFilterDef(
                factory = SnowballPorterFilterFactory.class,
                params = {
                    @Parameter(name = "language", value="English")
                }
            ),
            @TokenFilterDef(
                factory = ShingleFilterFactory.class,
                params = { 
                    @Parameter(name = "minShingleSize", value="2"),
                    @Parameter(name = "maxShingleSize", value="3"),
                    @Parameter(name = "outputUnigrams", value="true"),
                    @Parameter(name = "outputUnigramsIfNoShingles", value="false")
                }
            ),
            @TokenFilterDef(
                factory = PositionFilterFactory.class,
                params = {
                    @Parameter(name = "positionIncrement", value = "100")
                }
            ),
            @TokenFilterDef(
                factory = PhoneticFilterFactory.class,
                params = { 
                    @Parameter(name = "encoder", value="RefinedSoundex"),
                    @Parameter(name = "inject", value="true")
                }
            )
        }
),
@AnalyzerDef(
    name = "querytime",
    tokenizer = 
        @TokenizerDef(factory = StandardTokenizerFactory.class),
    filters = {
        @TokenFilterDef(factory = StandardFilterFactory.class),
        @TokenFilterDef(factory = LowerCaseFilterFactory.class),
        @TokenFilterDef(factory = StopFilterFactory.class,
            params = {
                @Parameter(name = "words", value = "data/ignorewords.txt"),
                @Parameter(name = "ignoreCase", value = "true")
            }
        ),
        @TokenFilterDef(
            factory = SnowballPorterFilterFactory.class,
            params = { 
                @Parameter(name = "language", value="English")
            }
        ),
        @TokenFilterDef(
            factory = ShingleFilterFactory.class,
            params = { 
                @Parameter(name = "minShingleSize", value="2"),
                @Parameter(name = "maxShingleSize", value="3"),
                @Parameter(name = "outputUnigrams", value="true"),
                @Parameter(name = "outputUnigramsIfNoShingles", value="false")
            }
        ),
        @TokenFilterDef(
            factory = PositionFilterFactory.class,
            params = {
                @Parameter(name = "positionIncrement", value = "100")
            }
        ),
        @TokenFilterDef(
            factory = PhoneticFilterFactory.class,
            params = { 
                @Parameter(name = "encoder", value="RefinedSoundex"),
                @Parameter(name = "inject", value="true")
            }
        )
    }
)
})

Above is my Analyzer Definition where i am using PatternTokenizerFactory at index time to index phrase with multiple words.
And another one with StandardTokenizerFactory with ShingleFilterFactory to be used at querytime but however I am not able to receive the combinations of tokens from my search query.
What i was expecting was : when the search query is My Search Query, it should have been my search and search query but instead i am getting my, search and query

Below is my function

FullTextSession fullTextSession = Search.getFullTextSession(session);
            Transaction tx = fullTextSession.beginTransaction();
            // create native Lucene query
            org.apache.lucene.search.Query luceneQuery = null;
            String[] fields = new String[] {"tags"}; 
            MultiFieldQueryParser parser = new MultiFieldQueryParser(
                    Version.LUCENE_31, fields, fullTextSession.getSearchFactory().getAnalyzer("querytime"));
            try {
                luceneQuery = parser.parse(searchQuery);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            // wrap Lucene query in a org.hibernate.Query
            org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(luceneQuery, CityArea.class);

            // execute search
            List result = hibQuery.list();

            tx.commit();
            session.close();
            return result;

The problem is my index token are for ex: say Word A, Word B and i am search for where is word a (so that it will display record of Word A) but no result. This is because i don’t want to display any result until the search query contains the phrase that is indexed.

  • 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-04T07:58:02+00:00Added an answer on June 4, 2026 at 7:58 am

    No answer from anybody lead myself to dig into the problem and found the answer myself. Since it may help others, i am writing it here and the solutions is pretty simple, just need to wrap the searchQuery into quotation marks.

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

Sidebar

Related Questions

I'm learning to work with lucene. I wrote a simple program to test lucene
Can someone help, i'm trying a simple example with hibernate search but getting the
I have a rather simple SOLR structure, that hold three different fields: id, text
I like to use Hibernate Search for implementing an sophisticated autosuggestion feature across multiple
I'm trying to extend Lucene's Analyzer from JRuby and use it from java. A

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.