ankitsultana commented on code in PR #12680: URL: https://github.com/apache/pinot/pull/12680#discussion_r1542177535
########## pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/LuceneTextIndexUtilsTest.java: ########## @@ -0,0 +1,100 @@ +/** + * 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.utils; + +import org.apache.lucene.index.Term; +import org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper; +import org.apache.lucene.queries.spans.SpanNearQuery; +import org.apache.lucene.queries.spans.SpanQuery; +import org.apache.lucene.queries.spans.SpanTermQuery; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.PrefixQuery; +import org.apache.lucene.search.RegexpQuery; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.WildcardQuery; +import org.testng.Assert; +import org.testng.annotations.Test; + + +public class LuceneTextIndexUtilsTest { + @Test + public void testBooleanQueryRewrittenToSpanQuery() { Review Comment: fyi: I used this code for testing and understanding the PR. The approach in this PR is quite interesting! https://gist.github.com/ankitsultana/88181cc3bda5113fec83175cfa867445 ########## pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/TextIndexConfig.java: ########## @@ -72,6 +74,8 @@ public TextIndexConfig(@JsonProperty("disabled") Boolean disabled, @JsonProperty luceneMaxBufferSizeMB == null ? LUCENE_INDEX_DEFAULT_MAX_BUFFER_SIZE_MB : luceneMaxBufferSizeMB; _luceneAnalyzerClass = (luceneAnalyzerClass == null || luceneAnalyzerClass.isEmpty()) ? FieldConfig.TEXT_INDEX_DEFAULT_LUCENE_ANALYZER_CLASS : luceneAnalyzerClass; + _enablePrefixSuffixMatchingInPhraseQueries = + enablePrefixSuffixMatchingInPhraseQueries == null ? false : enablePrefixSuffixMatchingInPhraseQueries; Review Comment: nit: hoist default false value to a static constant (similar to `LUCENE_INDEX_DEFAULT_USE_COMPOUND_FILE`). ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/text/LuceneTextIndexReader.java: ########## @@ -150,10 +155,14 @@ public MutableRoaringBitmap getDocIds(String searchQuery) { // be instantiated per query. Analyzer on the other hand is stateless // and can be created upfront. QueryParser parser = new QueryParser(_column, _analyzer); + parser.setAllowLeadingWildcard(true); Review Comment: in case you missed it: should we set this flag to true only when `_enablePrefixSuffixMatchingInPhraseQueries` is set to true? There are tradeoffs: without setting this to true the queries will fail directly. On the other hand, allowing it can risk expensive queries (per Lucene documentation). I am okay with either choice. -- 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]
