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


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/AlphanumericAnalyzer.java:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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.
+///
+/// On ASCII input this 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
+/// anything carrying status codes, ports, versions or generated identifiers.
+///
+/// Outside ASCII it is deliberately broader than those: a token character is 
whatever
+/// [Character#isLetterOrDigit(int)] accepts, so accented letters, CJK 
ideographs and Arabic-Indic
+/// digits are kept rather than treated as separators. `Café` yields `café`, 
where a `[a-zA-Z0-9]+`
+/// pattern tokenizer would cut it down to `caf`.
+///
+/// ## Token length
+///
+/// A run of token characters longer than [#MAX_TOKEN_LENGTH] is **split** at 
that boundary — not
+/// truncated and not dropped — which is the same limit and the same policy as

Review Comment:
   **[should-address] Describe 255 as a split threshold.** On Lucene 9.12.0, 
`"A".repeat(254) + "𐐀BC"` produces token lengths of 256 and 2 UTF-16 code units 
here. `StandardAnalyzer` produces lengths of 254 and 4 on the same input. 
`CharTokenizer` keeps the supplementary letter whole before checking the 
threshold. Please update the class and constant Javadocs, qualify the 
comparison with `StandardAnalyzer`, and cover this boundary with a 
supplementary-letter test.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/AlphanumericAnalyzer.java:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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.
+///
+/// On ASCII input this 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
+/// anything carrying status codes, ports, versions or generated identifiers.
+///
+/// Outside ASCII it is deliberately broader than those: a token character is 
whatever
+/// [Character#isLetterOrDigit(int)] accepts, so accented letters, CJK 
ideographs and Arabic-Indic
+/// digits are kept rather than treated as separators. `Café` yields `café`, 
where a `[a-zA-Z0-9]+`
+/// pattern tokenizer would cut it down to `caf`.
+///
+/// ## Token length
+///
+/// A run of token characters longer than [#MAX_TOKEN_LENGTH] is **split** at 
that boundary — not
+/// truncated and not dropped — which is the same limit and the same policy as
+/// [org.apache.lucene.analysis.standard.StandardAnalyzer]'s default. Two 
consequences matter for
+/// very long identifiers. The tail of an oversized run becomes a term in its 
own right, so a
+/// 257-character identifier is also matched by a term query for its last two 
characters. And a
+/// prefix, wildcard or fuzzy query longer than [#MAX_TOKEN_LENGTH] can never 
match, because such a

Review Comment:
   **[should-address] Scope the query-length claim to literal prefixes.** With 
`"A".repeat(255) + "BC"` indexed, I verified that `"A".repeat(255) + "X~1"` 
matches the 255-letter head through one edit. `"A".repeat(254) + "*A*"` also 
matches because `*` can consume zero characters. Please state that a literal 
prefix longer than every indexed term cannot match, and let fuzzy and wildcard 
matching follow their Lucene semantics.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/AlphanumericAnalyzer.java:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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.
+///
+/// On ASCII input this 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
+/// anything carrying status codes, ports, versions or generated identifiers.
+///
+/// Outside ASCII it is deliberately broader than those: a token character is 
whatever
+/// [Character#isLetterOrDigit(int)] accepts, so accented letters, CJK 
ideographs and Arabic-Indic
+/// digits are kept rather than treated as separators. `Café` yields `café`, 
where a `[a-zA-Z0-9]+`
+/// pattern tokenizer would cut it down to `caf`.
+///
+/// ## Token length
+///
+/// A run of token characters longer than [#MAX_TOKEN_LENGTH] is **split** at 
that boundary — not
+/// truncated and not dropped — which is the same limit and the same policy as
+/// [org.apache.lucene.analysis.standard.StandardAnalyzer]'s default. Two 
consequences matter for
+/// very long identifiers. The tail of an oversized run becomes a term in its 
own right, so a
+/// 257-character identifier is also matched by a term query for its last two 
characters. And a
+/// prefix, wildcard or fuzzy query longer than [#MAX_TOKEN_LENGTH] can never 
match, because such a
+/// query is normalized as one term and no indexed term is longer than that.
+///
+/// ## Switching an existing column to this analyzer
+///
+/// A text index records the analyzer it was built with, and the Lucene reader 
restores that saved
+/// configuration in preference to the current table config. A reload does not 
rebuild the index

Review Comment:
   **[should-address] Scope the rebuild instruction to single-column text 
indexes.** The example uses the single-column configuration. 
`MultiColumnTextIndexHandler.shouldModifyMultiColTextIndex` compares saved 
shared and per-column analyzer settings and detects changes to them on reload. 
Please name the single-column scope in this section so the manual rebuild 
instruction applies to the intended index type.



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