arunkumarucet opened a new pull request, #20292:
URL: https://github.com/apache/pinot/pull/20292

   Pinot's two text analyzers both mis-tokenize log and identifier-heavy text, 
in opposite directions:
   
   | Analyzer | `send_email` | `200` | `1YMWWN1N4O` |
   |---|---|---|---|
   | `StandardAnalyzer` (default) | `send_email` | `200` | `1ymwwn1n4o` |
   | `SimpleAnalyzer` | `send`, `email` | *(none)* | `ymwwn`, `n`, `o` |
   | `AlphanumericAnalyzer` (new) | `send`, `email` | `200` | `1ymwwn1n4o` |
   
   `StandardAnalyzer` follows UAX#29, so `send_email` and `email_server.rb` 
stay whole and a search for `email` misses them.
   
   `SimpleAnalyzer` splits on non-letters, but it is built on 
`LetterTokenizer`, so every digit is a **separator and is dropped** — `200` and 
`8080` produce no terms at all and can never be matched, `http2` is indexed as 
`http`, and an identifier such as `1YMWWN1N4O` shatters into letter fragments. 
Since Pinot applies the configured analyzer to queries as well as to documents, 
the term a user searches for is discarded in exactly the same way.
   
   ## What this adds
   
   `AlphanumericAnalyzer` splits on every non-alphanumeric character and 
lowercases by default — the tokenization most search engines use out of the box 
(Elasticsearch `char_group` + `lowercase`, ClickHouse `splitByNonAlpha`, a 
`[a-zA-Z0-9]+` pattern tokenizer). It is a good default for logs, URLs, stack 
traces, and anything carrying status codes, ports, versions or generated 
identifiers.
   
   - Token characters come from `Character#isLetterOrDigit`, so non-ASCII 
letters and digits (accented letters, CJK, Arabic-Indic digits) are kept rather 
than treated as separators.
   - An optional `caseSensitive` constructor argument mirrors the existing 
`CaseAwareStandardAnalyzer`.
   - `normalize()` is overridden so the terms of multi-term queries — wildcard, 
prefix, range, fuzzy, which Lucene never tokenizes — fold case the same way 
documents do.
   
   Opt in per column:
   
   ```json
   "properties": {
     "luceneAnalyzerClass": 
"org.apache.pinot.segment.local.segment.index.text.AlphanumericAnalyzer"
   }
   ```
   
   Optionally preserving case:
   
   ```json
   "properties": {
     "luceneAnalyzerClass": 
"org.apache.pinot.segment.local.segment.index.text.AlphanumericAnalyzer",
     "luceneAnalyzerClassArgs": "true",
     "luceneAnalyzerClassArgTypes": "java.lang.Boolean.TYPE"
   }
   ```
   
   ## Compatibility
   
   Additive and opt-in. No existing table changes behaviour; the default 
analyzer is untouched.
   
   ## Testing
   
   `AlphanumericAnalyzerTest` covers tokenization and lowercasing, digit 
preservation contrasted directly against `SimpleAnalyzer`, the cases where 
`StandardAnalyzer` keeps input whole, case-sensitive mode, `normalize()` for 
multi-term queries, non-ASCII token characters, instance reuse, and resolution 
through the real `TextIndexUtils.getAnalyzer` config path including the boolean 
constructor argument.
   
   ## Background
   
   This surfaced while running Pinot in 
[SearchBench](https://github.com/serenedb/searchbench), where the text-index 
column had to use `SimpleAnalyzer` to get word-level tokenization and 
consequently dropped every numeric term in the corpus.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to