dsmiley opened a new pull request, #3343: URL: https://github.com/apache/solr/pull/3343
This pull request refactors the Solr codebase to streamline the handling of `ValueSource` and `Query` objects by introducing a new `parseAsValueSource` method. This change reduces redundancy, simplifies logic, and improves maintainability by replacing repetitive patterns with a unified approach. The most significant changes include the removing some references to the `FunctionQuery` class and its associated logic, updates to various query parsers to use `parseAsValueSource`, and adjustments to related classes to align with these changes. ### Refactoring and Simplification: * **Introduction of `parseAsValueSource` Method:** - Added a new `parseAsValueSource` method to `QParser` and `FunctionQParser` to directly parse strings into `ValueSource` objects, replacing the need for intermediate `Query` objects. (`[[1]](diffhunk://#diff-a3f442b23b98fe2cac4b3cddd1d96c83cf073f02e1064373d87a14688ea9ff92R72-R80)`, `[[2]](diffhunk://#diff-7ee21ea338300a87cb0a790a61345efb8e85f11ee5271b5023d1a66a24e0fe15R334-R348)`) - Updated `FunctionQParser` to override `parseAsValueSource` and provide specialized parsing logic for function queries. (`[solr/core/src/java/org/apache/solr/search/FunctionQParser.javaR109-R120](diffhunk://#diff-a3f442b23b98fe2cac4b3cddd1d96c83cf073f02e1064373d87a14688ea9ff92R109-R120)`) * **Reduce usages of `FunctionQuery` and `QueryValueSource`:** - Reduced the references of `FunctionQuery` and `QueryValueSource` throughout the codebase by replacing them with the `parseAsValueSource` method. (`[[1]](diffhunk://#diff-5b2539b8b85fddfd4dd26488f19a3cadf364cbb943f54fe162994ecfe943f63dL33-L36)`, `[[2]](diffhunk://#diff-5d1602ad85ffd070bffbcfb68b6719687be44af06056bea42c376805bc3891e2L19-L22)`, `[[3]](diffhunk://#diff-0e9c04be7028a63fd51fabc30908d44f81099a6091171104b8613ed984aab8e7L31-L33)`) ### Updates to Query Parsers: * **Refactoring Query Parsers to Use `parseAsValueSource`:** - Replaced logic in multiple query parsers, such as `BoostQParserPlugin`, `FunctionRangeQParserPlugin`, and `ExtendedDismaxQParser`, to use `parseAsValueSource` instead of manually handling `FunctionQuery` and `QueryValueSource` objects. (`[[1]](diffhunk://#diff-5d1602ad85ffd070bffbcfb68b6719687be44af06056bea42c376805bc3891e2L59-R57)`, `[[2]](diffhunk://#diff-52a3282a50bdcd10163b46c82fea2d191cf6ddfca3d9269c533f876afe4a00faL53-R51)`, `[[3]](diffhunk://#diff-41949575f3350bb22b41f143983657b3f4ff4db362a694fc7a1365ad0dcc8b7cL535-R538)`) ### Code Cleanup: * **Simplified Parsing Logic:** - Simplified the parsing logic in `SolrReturnFields` and `SortSpecParsing` by delegating `ValueSource` parsing to the new method. (`[[1]](diffhunk://#diff-e72c1360a9b0097bcc01e269a94045ce5af1fdc93ae3021ca7e8d1b26d46bdcbL385-L425)`, `[[2]](diffhunk://#diff-a2f683125094cb0f507879a7d860db7bd3f76885d39dc619e0fe4210caf2666cL22-R22)`) These changes collectively improve the clarity and maintainability of the Solr codebase by unifying the handling of `ValueSource` objects and removing outdated constructs. _above generated by Copilot, with some editing on my part_. ---- Intended to be backported. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org