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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:11:54+00:00 2026-05-14T05:11:54+00:00

In the Lucene query syntax I’d like to combine * and ~ in a

  • 0

In the Lucene query syntax I’d like to combine * and ~ in a valid query similar to:
bla~* //invalid query

Meaning: Please match words that begin with “bla” or something similar to “bla”.

Update:
What I do now, works for small input, is use the following (snippet of SOLR schema):

<fieldtype name="text_ngrams" class="solr.TextField">
  <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
  </analyzer>
  <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>

In case you don’t use SOLR, this does the following.

Indextime: Index data by creating a field containing all prefixes of my (short) input.

Searchtime: only use the ~ operator, as prefixes are explicitly present in the index.

  • 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-14T05:11:55+00:00Added an answer on May 14, 2026 at 5:11 am

    I do not believe Lucene supports anything like this, nor do I believe it has a trivial solution.

    “Fuzzy” searches do not operate on a fixed number of characters. bla~ may for example match blah and so it must consider the entire term.

    What you could do is implement a query expansion algorithm that took the query bla~* and converted it into a series of OR queries

    bla* OR blb* OR blc OR .... etc.
    

    But that is really only viable if the string is very short or if you can narrow the expansion based on some rules.

    Alternatively if the length of the prefix is fixed you could add a field with the substrings and perform the fuzzy search on that. That would give you what you want, but will only work if your use case is sufficiently narrow.

    You don’t specify exactly why you need this, perhaps doing so will elicit other solutions.

    One scenario I can think of is dealing with different form of words. E.g. finding car and cars.

    This is easy in English as there are word stemmers available. In other languages it can be quite difficult to implement word stemmers, if not impossible.

    In this scenario you can however (assuming you have access to a good dictionary) look up the search term and expand the search programmatically to search for all forms of the word.

    E.g. a search for cars is translated into car OR cars. This has been applied successfully for my language in at least one search engine, but is obviously non-trivial to implement.

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

Sidebar

Related Questions

Google's query syntax allows to search phrases like as * as a skyscraper where
I read that Lucene has an internal query language where one specifies : and
I'm having an issue with Lucene's Term [Boosting][1] query syntax, specifically in Ruby on
is it possible to make Lucene query in alfresco that finds nodes based on
I'm crashing into a weird behavior with - operators in Solr/Lucene query syntax. If
Normally when using Lucene you set a search query and Lucene gives you some
Hits hits = searcher.Search(query); Warning 1 'Lucene.Net.Search.Hits' is obsolete: 'see Searcher.Search(Query, int), Searcher.Search(Query, Filter,
I'm trying to come up with a way to query dates in Lucene. Basically
The Lucene documents tell me that Hits will be removed from the API in
Is it possible to query an Index made with Lucene.NET through a PHP front-end?

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.