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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:53:42+00:00 2026-06-14T12:53:42+00:00

I’m creating a dictionary app that searches both a word and its definition (two

  • 0

I’m creating a dictionary app that searches both a word and its definition (two separate Fields). However, using a StandardAnalyzer, no search results are returned when the search string contains whitespace or special characters.

For example, in my dummy dictionary data, searching “lorem” searches all words that have “lorem” in their definitions, but searching for “lorem ipsum” returns nothing, even though most of my dummy words have a lorem ipsum in the definition.

Also, searching for words like “make-believe” only returns results when typing “make,” but as soon as I include the dash, nothing is returned.

I want to include characters like whitespace, dashes, commas, whatever–basically everything in the search string (except perhaps the nonsense words like “and,” “at,” “by,” etc.), but what analyzer should I use? I’ve tried PatternAnalyzer and supplied .+ as the Pattern to look for but typing even just a single letter returns nothing.

  • 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-14T12:53:43+00:00Added an answer on June 14, 2026 at 12:53 pm

    I stuck with a StandardAnalyzer since there doesn’t seem to be an alternative. What I did is tokenize the string via a regex that captures non-word characters, combine them in an AND BooleanQuery, and combine the query for the two Fields in another OR BooleanQuery.

    In my code below, entry is the word, description is the definition, and s is the search string as a CharSequence.

    BooleanQuery bq = new BooleanQuery();
    BooleanQuery entryBQ = new BooleanQuery();
    BooleanQuery descriptionBQ = new BooleanQuery();
    String[] tokens = String.valueOf(s).split("[^a-zA-Z0-9]");
    for (String token : tokens) {
        if (token.isEmpty()) continue;
        entryBQ.add(new WildcardQuery(new Term("entry", token + "*")), BooleanClause.Occur.MUST);
        descriptionBQ.add(new WildcardQuery(new Term("description", token + "*")), BooleanClause.Occur.MUST);
    }
    bq.add(entryBQ, BooleanClause.Occur.SHOULD);
    bq.add(descriptionBQ, BooleanClause.Occur.SHOULD);
    TopScoreDocCollector collector = TopScoreDocCollector.create(10, true);
    is.search(bq, collector);
    

    This is horrendously slow in my Android app right now but I can optimize it later. 🙂

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace

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.