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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:25:05+00:00 2026-05-23T19:25:05+00:00

I am doing some test using WordDelimiterFilter in Solr but it doesn’t preserve the

  • 0

I am doing some test using WordDelimiterFilter in Solr but it doesn’t preserve the protected list of words which I pass to it. Would you please inspect the code and the output example and suggest which part is missing or used badly?

with running this code:

private static Analyzer getWordDelimiterAnalyzer() {
    return new Analyzer() {
        @Override
        public TokenStream tokenStream(String fieldName, Reader reader) {
            TokenStream stream = new StandardTokenizer(Version.LUCENE_32, reader);
            WordDelimiterFilterFactory wordDelimiterFilterFactory = new WordDelimiterFilterFactory();
            HashMap<String, String> args = new HashMap<String, String>();
            args.put("generateWordParts", "1");
            args.put("generateNumberParts", "1");
            args.put("catenateWords", "1");
            args.put("catenateNumbers", "1");
            args.put("catenateAll", "0");
            args.put("luceneMatchVersion", Version.LUCENE_32.name());
            args.put("language", "English");
            args.put("protected", "protected.txt");
            wordDelimiterFilterFactory.init(args);
            ResourceLoader loader = new SolrResourceLoader(null, null);
            wordDelimiterFilterFactory.inform(loader);
            /*List<String> protectedWords = new ArrayList<String>();
            protectedWords.add("good bye");
            protectedWords.add("hello world");
            wordDelimiterFilterFactory.inform(new LinesMockSolrResourceLoader(protectedWords));
            */
            return wordDelimiterFilterFactory.create(stream);
        }
    };
}

input text:

hello world

good bye

what is your plan for future?


protected strings:

good bye

hello world


output:

(hello,startOffset=0,endOffset=5,positionIncrement=1,type=)

(world,startOffset=6,endOffset=11,positionIncrement=1,type=)

(good,startOffset=12,endOffset=16,positionIncrement=1,type=)

(bye,startOffset=17,endOffset=20,positionIncrement=1,type=)

(what,startOffset=21,endOffset=25,positionIncrement=1,type=)

(is,startOffset=26,endOffset=28,positionIncrement=1,type=)

(your,startOffset=29,endOffset=33,positionIncrement=1,type=)

(plan,startOffset=34,endOffset=38,positionIncrement=1,type=)

(for,startOffset=39,endOffset=42,positionIncrement=1,type=)

(future,startOffset=43,endOffset=49,positionIncrement=1,type=)

  • 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-23T19:25:05+00:00Added an answer on May 23, 2026 at 7:25 pm

    You are using a standard tokenizer which at least tokenizes on a whitespace level so you will always have “hello world” be split to “hello” and “world”.

    TokenStream stream = new StandardTokenizer(Version.LUCENE_32, reader);
    

    See Lucene Documentation:

    public final class StandardTokenizer extends Tokenizer

    A grammar-based tokenizer constructed with JFlex

    This should be a good tokenizer for most European-language documents:

    Splits words at punctuation characters, removing punctuation.
    However, a dot that’s not followed by whitespace is considered part of
    a token.

    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.

    Recognizes email addresses and internet hostnames as one token.

    The word delimiter protected word list is meant for something like:

    • ISBN2345677 to be split in ISBN 2345677
    • text2html not to be split in text 2 html (because text2html was added to protected words)

    If you really want to do something like you mentioned you may use the KeywordTokenizer. But you have to do the complete splitting by yourself.

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

Sidebar

Related Questions

I've been doing some HTML scraping in PHP using regular expressions. This works, but
I have been looking in to doing some test driven development for one of
I am doing some simple sanity validation on various types. The current test I'm
I'm doing some funky authentication work (and yes, I know, open-id is awesome, but
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I'm doing some Android development, and I much prefer Visual Studio, but I'll have
I have been doing some research on test driven development and find it pretty
I have been doing some OO Perl programming and I was wondering: which is
I am currently doing some socket programming using C/C++. To be able to use
I'm doing some geocoding using the google maps API. The user fill a form

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.