-
Notifications
You must be signed in to change notification settings - Fork 141
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integ match bool prefix #187 #634
Merged
joshuali925
merged 41 commits into
opensearch-project:main
from
Bit-Quill:integ-match_bool_prefix-#187
Jun 27, 2022
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a422774
Support MATCH_BOOL_PREFIX in SQL parser.
838da0f
Add an interface for PPL and SQL parsers.
f57429c
Implement Parser interface on PPLSyntaxParser.
e80a334
Add base class for all SQL tests.
531f31c
Add match_bool_prefix to list of known functions.
1b85a9e
Add match_bool_prefix to DSL.
dd4f77b
Add MatchBoolPrefixQuery query builder.
1ba94d9
Add MatchBoolPrefixQuery to FilterQueryBuilder.
1855e39
Address PR comments.
4321fc1
100% unit test coverage for RelevanceQuery class.
92087d9
Add integration test for match_bool_prefix in SQL.
56ead1b
Enable MatchBoolPrefixParserTest tests since they now pass.
a149dd7
Add user documentation for match_bool_prefix.
5ccadd5
Merge from upstream/main and resolve conflicts.
028281b
Merge branch 'opensearch-project-main'
2f664ac
Adding parameter options parser tests
forestmvey 9f565b3
Add match_bool_prefix optional parameters to relevance function
forestmvey 46b1116
Adding optional parameter integration tests
forestmvey 0ba4e35
Updating match_bool_prefix documentation
forestmvey 5798b06
Adding match_bool_prefix unit tests
forestmvey dfad749
Fixing documentation test
forestmvey 70f6a21
Adding missing newline
forestmvey ef085e0
Merge from upstream/main and resolve conflicts. Part 2.
500c554
Fixing compilation errors, checkstyle errors, and code coverage
forestmvey 9c102d6
Merge branch 'dev-match_bool_prefix-#187' into dev-match_bool_prefix-…
forestmvey 7315f49
Aggregated additional parameters into one test and renamed test function
forestmvey 3743bbd
Reverting unnecessary file formatting
forestmvey 3f6ac10
Merge pull request #64 from Bit-Quill/dev-match_bool_prefix-2#187
forestmvey f792e95
Adding PPL syntax, documentation, integration tests, and PPL tests
forestmvey b625276
Make PPL integration test queries more appropriately match relevance …
forestmvey 9b0eeb9
Merge pull request #67 from Bit-Quill/dev-match_bool_prefix-ppl#187
forestmvey 0bcc123
Merge pull request #69 from Bit-Quill/dev-match_bool_prefix-#187
forestmvey 37992ac
Add analyzer and operator parameters to match_bool_prefix in sql and ppl
111a8e6
Update SQL and PPL documentation.
2d2ddf8
Merge pull request #72 from Bit-Quill/dev-match_bool_prefix-#187-more…
MaxKsyunz 0a08ce4
Merge remote-tracking branch 'upstream/main' into integ-match_bool_pr…
eefa7e6
Adding newline to functions.rst to fix doctest.
6a8fa69
Update test to use PPLSyntaxParser.parse instead of analyzeSyntax.
76b9158
Merge remote-tracking branch 'upstream/main' into integ-match_bool_pr…
686e9f2
Update analyzeSyntax to parse in PPL parser unit tests.
df48828
Move limitations section to the end of the document.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
common/src/main/java/org/opensearch/sql/common/antlr/Parser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.opensearch.sql.common.antlr; | ||
|
||
import org.antlr.v4.runtime.tree.ParseTree; | ||
|
||
public interface Parser { | ||
ParseTree parse(String query); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ppl; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PHRASE; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
|
||
public class MatchBoolPrefixIT extends PPLIntegTestCase { | ||
|
||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.PHRASE); | ||
} | ||
|
||
@Test | ||
public void valid_query_match_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, 'qui') | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
verifyDataRows(result, | ||
rows("quick fox"), | ||
rows("quick fox here")); | ||
} | ||
|
||
@Test | ||
public void optional_parameter_match_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, '2 tes', minimum_should_match=1, fuzziness=2) | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
verifyDataRows(result, | ||
rows("my test"), | ||
rows("my test 2")); | ||
} | ||
|
||
@Test | ||
public void no_matches_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, 'rice') | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
assertEquals(0, result.getInt("total")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
integ-test/src/test/java/org/opensearch/sql/sql/MatchBoolPrefixIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PHRASE; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.schema; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifySchema; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
public class MatchBoolPrefixIT extends SQLIntegTestCase { | ||
public void init() throws IOException { | ||
loadIndex(SQLIntegTestCase.Index.PHRASE); | ||
} | ||
|
||
@Test | ||
public void query_matches_test() throws IOException { | ||
String query = "SELECT phrase FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, 'quick')"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
verifySchema(result, schema("phrase", "text")); | ||
|
||
verifyDataRows(result, | ||
rows("quick fox"), | ||
rows("quick fox here")); | ||
} | ||
|
||
@Test | ||
public void additional_parameters_test() throws IOException { | ||
String query = "SELECT phrase FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, '2 test', minimum_should_match=1, fuzziness=2)"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
verifySchema(result, schema("phrase", "text")); | ||
|
||
verifyDataRows(result, | ||
rows("my test"), | ||
rows("my test 2")); | ||
} | ||
|
||
@Test | ||
public void no_matches_test() throws IOException { | ||
String query = "SELECT * FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, 'rice')"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
assertEquals(0, result.getInt("total")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -594,4 +594,4 @@ public void fieldWithSpacesInNameShouldPass() { | |
Assert.assertSame(TEXT, type.get()); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 you know if the meaning of these params documented in OpenSearch doc or not? I don't see it here: https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#match-boolean-prefix. I'm thinking if it's missing, probably we can add it in our 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.
@dai-chen
Optional arguments are available in the options section of that page.
https://opensearch.org/docs/latest/opensearch/query-dsl/full-text/#options
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.
Got it. I missed it. Thanks!