- Notifications
You must be signed in to change notification settings - Fork101
feat: add OpenSearch distance operations and selectors#1335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
jgaleotti left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
please add test cases for the classes OpenSearchHeuristicsCalculator, ParameterExtractor and OpenSearchQueryHelper
| importorg.evomaster.client.java.controller.opensearch.selectors.MatchSelector; | ||
| importorg.evomaster.client.java.controller.opensearch.selectors.QuerySelector; | ||
| publicclassOpenSearchQueryParser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We need tests for OpenSearchQueryParser to check that the JSON is correctly parsed into its corresponding OpenSearch operation.
| /** | ||
| * Utility class to extract common parameters and reduce code duplication in selectors. | ||
| */ | ||
| publicclassParameterExtractor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
add test cases for this class
| /** | ||
| * Extracts the case_insensitive parameter from a term query object. | ||
| */ | ||
| publicstaticBooleanextractCaseInsensitive(Objectquery,Stringstructure) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
add test cases for this class
arcuri82 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
sorry for late check, but was on vacation most of last week
| if (operationinstanceofMatchOperation) { | ||
| returncalculateDistanceForMatch((MatchOperation)operation,doc); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
shouldn't these be a chain of if/else, with a final having a warn log if no match was present? (eg to see if we miss any case).
| // Not enough matches - distance based on how many more matches needed | ||
| intshortfall =minimumRequired -matchCount; | ||
| // Return a distance that reflects both the shortfall and the quality of non-matching terms | ||
| returnshortfall *10.0 + (totalDistance /expectedTerms.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
what ifexpectedTerms.size() is 0?
| try { | ||
| // Create pattern with case insensitive flag if needed | ||
| java.util.regex.Patternpattern; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
are the regex in OpenSearch having the same syntax of Java regex? clarify here in some comments, with possible some links
mmiguerodriguezNov 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
OpenSearch uses Lucene regular expression syntax, which is similar but NOT identical to Java regex.
https://opensearch.org/docs/latest/query-dsl/term/regexp/
https://lucene.apache.org/core/8_0_0/core/org/apache/lucene/util/automaton/RegExp.html
@jgaleotti Do you consider adding Java Regexp for this heuristic calculation as acceptable?
| // Helper methods for advanced operations | ||
| privateintcalculateEditDistance(Strings1,Strings2,booleanallowTranspositions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
geneneric helper functions on strings should not be here, but rather inclient-java/distance-heuristics/src/main/java/org/evomaster/client/java/distance/heuristics/DistanceHelper.java
| // } | ||
| @GetMapping("gte/{gte}") | ||
| publicList<Age>findGteAge(@PathVariable("gte")Integergte)throwsIOException { | ||
| returnageRepo.findGteAge(gte); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
all these endpoints should return 404 if no data is found
| Solution<RestIndividual>solution =initAndRun(args); | ||
| // assertHasAtLeastOne(solution, HttpVerb.GET, 404, "/students/{q}", null); | ||
| assertHasAtLeastOne(solution,HttpVerb.GET,200,"/students/{lastName}",null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
add assertions for both 404 and 200 cases
| // Term selector tests | ||
| @GetMapping("category/{category}") | ||
| publicList<Product>findByCategory(@PathVariableStringcategory)throwsIOException { | ||
| returnproductRepository.findByCategory(category); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
do return 404 if nothing is found in these endpoints, as it will simplify writing assertions/checks in the tests
| Solution<RestIndividual> solution = initAndRun(args); | ||
| assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/queries/category/{category}", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
add assertions on 404
| } | ||
| @Test | ||
| public void testRangeQueries() throws Throwable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why are these E2E repeated with same configurations? can have single tests with all the assertions.
otherwise, if you only want to test specific endpoints, you have to passargs parameters to specify them, eg, with--endpointPrefix
| @@ -0,0 +1,21 @@ | |||
| package com.opensearch.queries; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
foldere2e-tests does not exist any more (we did a major refactoring of folder structures recently)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Changing that.
mmiguerodriguez commentedNov 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@arcuri82 is there any known issue with the Is there any way to prevent those errors? |
arcuri82 commentedNov 20, 2025
@mmiguerodriguez hi. there is no known current issue about |
mmiguerodriguez commentedNov 20, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm not completely sure what was the issue, perhaps different Java version used by Maven and IntelliJ builds... I'll be reviewing why there's some errors on the build/tests. I've already made some of the adjustements. |
arcuri82 commentedNov 20, 2025
@mmiguerodriguez ah, yes. we moved to JDK 17 recently... and might move to 21 in the near future |
mmiguerodriguez commentedNov 20, 2025
We'll need to adjust |
arcuri82 commentedNov 20, 2025
@mmiguerodriguez good point! i ll do now |
No description provided.