arunkumarucet commented on code in PR #20292:
URL: https://github.com/apache/pinot/pull/20292#discussion_r4663989557


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/AlphanumericAnalyzer.java:
##########
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.segment.local.segment.index.text;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.LowerCaseFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.CharTokenizer;
+
+
+/// An [Analyzer] that splits on every non-alphanumeric character and, by 
default, lowercases the
+/// result — so `email_server.rb` yields `email`, `server`, `rb`, and `HTTP2` 
yields `http2`.
+///
+/// This fills a gap between the two analyzers Pinot already offers for log 
and identifier-heavy
+/// text, neither of which tokenizes the way most search engines do:
+///
+/// | Analyzer | `send_email` | `200` | `1YMWWN1N4O` |
+/// |---|---|---|---|
+/// | [org.apache.lucene.analysis.standard.StandardAnalyzer] (default) | 
`send_email` | `200` | `1ymwwn1n4o` |
+/// | [org.apache.lucene.analysis.core.SimpleAnalyzer] | `send`, `email` | 
*(none)* | `ymwwn`, `n`, `o` |
+/// | `AlphanumericAnalyzer` | `send`, `email` | `200` | `1ymwwn1n4o` |
+///
+/// [org.apache.lucene.analysis.standard.StandardAnalyzer] follows UAX#29, 
which keeps
+/// `send_email` and `email_server.rb` whole, so a search for `email` does not 
match them.
+/// [org.apache.lucene.analysis.core.SimpleAnalyzer] splits on non-letters, 
but because it is built
+/// on [org.apache.lucene.analysis.core.LetterTokenizer] 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. Pinot applies
+/// the configured analyzer to queries as well as to documents, so the term a 
user searches for is
+/// discarded in exactly the same way.
+///
+/// This analyzer is the behaviour of Elasticsearch's `char_group` tokenizer 
over whitespace,
+/// punctuation and symbols plus `lowercase`, of ClickHouse's 
`splitByNonAlpha`, and of a
+/// `[a-zA-Z0-9]+` pattern tokenizer. It is a good default for logs, URLs, 
stack traces, and

Review Comment:
   Fair — the comparison was only true for ASCII. Reworded: the Elasticsearch 
`char_group` + `lowercase`, ClickHouse `splitByNonAlpha` and `[a-zA-Z0-9]+` 
equivalence is now scoped to ASCII input, followed by a paragraph saying a 
token character is whatever `Character.isLetterOrDigit` accepts, using your 
example — `Café` yields `café` here, where `[a-zA-Z0-9]+` would cut it to 
`caf`. The existing `testNonAsciiLettersAndDigitsAreTokenCharacters` already 
pins that behaviour.



-- 
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