raghavyadav01 commented on code in PR #16147:
URL: https://github.com/apache/pinot/pull/16147#discussion_r2162516226


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/LuceneTextIndexUtils.java:
##########
@@ -72,4 +81,202 @@ public static Query convertToMultiTermSpanQuery(Query 
query) {
     LOGGER.debug("The phrase query {} is re-written as {}", query, 
spanNearQuery);
     return spanNearQuery;
   }
+
+  /**
+   * Parses search options from a search query string.
+   * The options can be specified anywhere in the query using __OPTIONS(...) 
syntax.
+   * For example: "term1 __OPTIONS(parser=CLASSIC) AND term2 
__OPTIONS(analyzer=STANDARD)"
+   * Options from later occurrences will override earlier ones.
+   *
+   * @param searchQuery The search query string
+   * @return A Map.Entry containing the cleaned search term and options map, 
or null if no options found
+   */
+  public static Map.Entry<String, Map<String, String>> 
parseOptionsFromSearchString(String searchQuery) {
+    try {
+      // Early check for __OPTIONS to avoid unnecessary processing
+      if (searchQuery == null || !searchQuery.contains("__OPTIONS")) {
+        return null;
+      }
+
+      // Pattern to match __OPTIONS(...) with word boundaries
+      // (?<!\\\\) - negative lookbehind to avoid escaped __OPTIONS
+      // \\b - word boundary to ensure __OPTIONS is standalone
+      // __OPTIONS\\((.*?)\\) - non-greedy match for content inside parentheses
+      Pattern pattern = Pattern.compile("(?<!\\\\)\\b__OPTIONS\\((.*?)\\)");

Review Comment:
   @Jackie-Jiang I have made the changes to take third param in TEXT_MATCH to 
provide additional options/context to text search. 



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to