-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assorted jinjava template changes for replayer...
Switched out Google's re2j for Java's implementation. I didn't realize that the java implementation is closer to python regexes and that re2j (which I had thought was closer to python). Minor tweaks to the route jinja template to make it easier to read when it's invoked. Switched the replayer template to use the route functionality, which is considerably easier to get one's head around. TODO - * I'd like to make the feature flag names the same as the macro name for the route when the feature flag name is omitted. * The test cases for the type mappings sanitization need a lot of work. * When indices are created that DO NOT use type mappings, we should handle those more gracefully. Signed-off-by: Greg Schohn <[email protected]>
- Loading branch information
1 parent
e8dfb3f
commit b1f3756
Showing
7 changed files
with
80 additions
and
73 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
...sformer/src/main/java/org/opensearch/migrations/transform/jinjava/RegexCaptureFilter.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
25 changes: 0 additions & 25 deletions
25
...MessageTransformers/jsonJinjavaTransformer/src/main/resources/jinjava/common/route-bkp.j2
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
...jsonMessageTransformers/jsonJinjavaTransformer/src/main/resources/jinjava/common/route.j2
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package org.opensearch.migrations.transform; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -21,23 +23,61 @@ static void initialize() throws IOException { | |
"type2", "indexB"), | ||
"indexC", Map.of( | ||
"type2", "indexC")); | ||
//"time-(*)", Map.of("(*)", "time-\\1-\\2")); | ||
indexTypeMappingRewriter = new TypeMappingsSanitizationTransformer(indexMappings); | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
public void testPutDoc() throws Exception { | ||
var testString = | ||
"{\n" + | ||
" \"verb\": \"PUT\",\n" + | ||
" \"uri\": \"/indexA/type2/someuser\",\n" + | ||
" \"body\": {\n" + | ||
" \"name\": \"Some User\",\n" + | ||
" \"user_name\": \"user\",\n" + | ||
" \"email\": \"[email protected]\"\n" + | ||
" }\n" + | ||
"}"; | ||
"{\n" + | ||
" \"" + JsonKeysForHttpMessage.METHOD_KEY + "\": \"PUT\",\n" + | ||
" \"" + JsonKeysForHttpMessage.URI_KEY + "\": \"/indexA/type2/someuser\",\n" + | ||
" \"" + JsonKeysForHttpMessage.PAYLOAD_KEY + "\": {\n" + | ||
" \"" + JsonKeysForHttpMessage.INLINED_JSON_BODY_DOCUMENT_KEY + "\": {" + | ||
" \"name\": \"Some User\",\n" + | ||
" \"user_name\": \"user\",\n" + | ||
" \"email\": \"[email protected]\"\n" + | ||
" }\n" + | ||
" }\n" + | ||
"}"; | ||
var objMapper = new ObjectMapper(); | ||
var resultObj = indexTypeMappingRewriter.transformJson(objMapper.readValue(testString, Map.class)); | ||
var resultObj = indexTypeMappingRewriter.transformJson(objMapper.readValue(testString, LinkedHashMap.class)); | ||
var resultStr = objMapper.writeValueAsString(resultObj); | ||
System.out.println("resultStr = " + resultStr); | ||
} | ||
|
||
@Test | ||
public void testPutIndex() throws Exception { | ||
var testString = | ||
"{\n" + | ||
" \"" + JsonKeysForHttpMessage.METHOD_KEY + "\": \"PUT\",\n" + | ||
" \"" + JsonKeysForHttpMessage.URI_KEY + "\": \"/indexA\",\n" + | ||
" \"" + JsonKeysForHttpMessage.PAYLOAD_KEY + "\": {\n" + | ||
" \"" + JsonKeysForHttpMessage.INLINED_JSON_BODY_DOCUMENT_KEY + "\": " + | ||
"{\n" + | ||
" \"mappings\": {\n" + | ||
" \"user\": {\n" + | ||
" \"properties\": {\n" + | ||
" \"name\": { \"type\": \"text\" },\n" + | ||
" \"user_name\": { \"type\": \"keyword\" },\n" + | ||
" \"email\": { \"type\": \"keyword\" }\n" + | ||
" }\n" + | ||
" },\n" + | ||
" \"tweet\": {\n" + | ||
" \"properties\": {\n" + | ||
" \"content\": { \"type\": \"text\" },\n" + | ||
" \"user_name\": { \"type\": \"keyword\" },\n" + | ||
" \"tweeted_at\": { \"type\": \"date\" }\n" + | ||
" }\n" + | ||
" }\n" + | ||
" }\n" + | ||
"}" + | ||
"\n" + | ||
" }\n" + | ||
"}"; | ||
var objMapper = new ObjectMapper(); | ||
var resultObj = indexTypeMappingRewriter.transformJson(objMapper.readValue(testString, LinkedHashMap.class)); | ||
var resultStr = objMapper.writeValueAsString(resultObj); | ||
System.out.println("resultStr = " + resultStr); | ||
} | ||
|