Skip to content

Commit

Permalink
Resolve merge conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chu <[email protected]>
  • Loading branch information
noCharger committed May 22, 2023
1 parent ba8a1f7 commit c04f202
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Processor that evaluates a script with a search request in its context
* and then returns the modified search request.
*/
public final class ScriptProcessor extends AbstractProcessor implements SearchRequestProcessor {
public final class ScriptRequestProcessor extends AbstractProcessor implements SearchRequestProcessor {
/**
* Key to reference this processor type from a search pipeline.
*/
Expand All @@ -57,7 +57,7 @@ public final class ScriptProcessor extends AbstractProcessor implements SearchRe
* @param precompiledSearchScript The {@link Script} precompiled
* @param scriptService The {@link ScriptService} used to execute the script.
*/
ScriptProcessor(
ScriptRequestProcessor(
String tag,
String description,
Script script,
Expand Down Expand Up @@ -124,9 +124,9 @@ SearchScript getPrecompiledSearchScript() {
}

/**
* Factory class for creating {@link ScriptProcessor}.
* Factory class for creating {@link ScriptRequestProcessor}.
*/
public static final class Factory implements Processor.Factory {
public static final class Factory implements Processor.Factory<SearchRequestProcessor> {
private final ScriptService scriptService;

/**
Expand All @@ -139,18 +139,18 @@ public Factory(ScriptService scriptService) {
}

/**
* Creates a new instance of {@link ScriptProcessor}.
* Creates a new instance of {@link ScriptRequestProcessor}.
*
* @param registry The registry of processor factories.
* @param processorTag The processor's tag.
* @param description The processor's description.
* @param config The configuration options for the processor.
* @return The created {@link ScriptProcessor} instance.
* @return The created {@link ScriptRequestProcessor} instance.
* @throws Exception if an error occurs during the creation process.
*/
@Override
public ScriptProcessor create(
Map<String, Processor.Factory> registry,
public ScriptRequestProcessor create(
Map<String, Processor.Factory<SearchRequestProcessor>> registry,
String processorTag,
String description,
Map<String, Object> config
Expand All @@ -175,7 +175,7 @@ public ScriptProcessor create(
} catch (ScriptException e) {
throw newConfigurationException(TYPE, processorTag, null, e);
}
return new ScriptProcessor(processorTag, description, script, searchScript, scriptService);
return new ScriptRequestProcessor(processorTag, description, script, searchScript, scriptService);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public Map<String, Processor.Factory<SearchRequestProcessor>> getRequestProcesso
return Map.of(
FilterQueryRequestProcessor.TYPE,
new FilterQueryRequestProcessor.Factory(parameters.namedXContentRegistry),
ScriptProcessor.TYPE,
new ScriptProcessor.Factory(parameters.scriptService)
ScriptRequestProcessor.TYPE,
new ScriptRequestProcessor.Factory(parameters.scriptService)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static org.hamcrest.core.Is.is;
import java.util.concurrent.TimeUnit;

public class ScriptProcessorTests extends OpenSearchTestCase {
public class ScriptRequestProcessorTests extends OpenSearchTestCase {

private ScriptService scriptService;
private Script script;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void setupScripting() {
}

public void testScriptingWithoutPrecompiledScriptFactory() throws Exception {
ScriptProcessor processor = new ScriptProcessor(randomAlphaOfLength(10), null, script, null, scriptService);
ScriptRequestProcessor processor = new ScriptRequestProcessor(randomAlphaOfLength(10), null, script, null, scriptService);
SearchRequest searchRequest = new SearchRequest();
searchRequest.source(createSearchSourceBuilder());

Expand All @@ -92,7 +92,7 @@ public void testScriptingWithoutPrecompiledScriptFactory() throws Exception {
}

public void testScriptingWithPrecompiledIngestScript() throws Exception {
ScriptProcessor processor = new ScriptProcessor(randomAlphaOfLength(10), null, script, searchScript, scriptService);
ScriptRequestProcessor processor = new ScriptRequestProcessor(randomAlphaOfLength(10), null, script, searchScript, scriptService);
SearchRequest searchRequest = new SearchRequest();
searchRequest.source(createSearchSourceBuilder());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,49 @@ teardown:
- is_false: hits.hits.0._primary_term
- is_false: hits.hits.1._primary_term
- is_false: profile

---
"Test unsupported operations in script processor":
- do:
search_pipeline.put:
id: "my_pipeline"
body: >
{
"description": "_description",
"request_processors": [
{
"script" : {
"lang": "painless",
"source" : "int a = ctx.dummy;"
}
}
]
}
- match: { acknowledged: true }

- do:
index:
index: test
id: 1
body: {
"field": "foo"
}
- do:
index:
index: test
id: 2
body: {
"field": "value"
}

- do:
indices.refresh:
index: test

- do:
catch: bad_request
search:
index: test
search_pipeline: "my_pipeline"
body: { }
- match: { status: 400 }

0 comments on commit c04f202

Please sign in to comment.