Which analyzer(s) / tokenizer(s) for specific ID?

I have a problem (I’m sure there is a solution).
I would like to be able to search for a specific ID.
How do I have to analyze the field so that I can search for the ID?
ID number 1:
I want to perform the following search:

ID number 2:
TEST #: 2021-006011-26
I would like to perform the following search:
test #*
test #:*
test #: 2021*
test #: 2021-*
TEST #: 2021-006011-26*

Any help would be greatly appreciated.


So essentially you simply want case-insensitive prefix search?

What was wrong with my answer to your previous, similar question?

It should work similarly for an ID field. You will just have to declare new analyzers where you remove unnecessary analysis components, such as the tokenizer (replace it with a KeywordTokenizer) and the SnowballPorterFilterFactory (remove it, you don’t need it for IDs).

Alternatively, you can use a @KeywordField with a simple “lowercasing” normalizer (similar to the one named lowercase in this example), and rely on a wildcard predicate. It’s less flexible, but should work for simple use cases.

Hello, as always thanks for the quick reply.
I would like to be able to analyze the fields with “-” , “#” , “:” to be able to analyze and also search with or without these special characters.
My problem is, unfortunately I don’t know which analyzer/tokenizer to use at this point.
It should be indexed like this.
EXAMPLE: TEST #: 2021-006011-26
=> “TEST”, “#”, “TEST #:”, “2021” “2021-” and so on.

Your examples in the initial post don’t seem to require this indexing.

From what I can see in these examples, you simply need to not tokenize at all, i.e. TEST #: 2021-006011-26 would be indexed as:

  • t
  • te
  • tes
  • test
  • test
  • test #
  • test #:
  • test #:
  • test #: 2
  • etc.

What is the exact code you’re using to search, what is your mapping, and what are the exact search strings that do not match as expected?