Skip to content

Commit

Permalink
Addressing martin comments
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Dec 28, 2023
1 parent 88823b3 commit de02df2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void testSemanticSearch() throws Exception{
assertNotNull(pipeline);
String modelId=getModelId(pipeline, TEXT_EMBEDDING_PROCESSOR);
validateTestIndex(modelId);
deletePipeline(PIPELINE_NAME);
deleteModel(modelId);
deleteIndex(testIndex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"refresh_interval": "30s",
"default_pipeline": "%s"
},
"number_of_shards": 1,
"number_of_replicas": 0
"number_of_shards": 6,
"number_of_replicas": 2
},
"mappings": {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void testSemanticSearch() throws Exception{
int totalDocsCountUpgraded=3*NUM_DOCS;
addDocument(testIndex, "2",TEST_FIELD,TEXT_UPGRADED);
validateTestIndexOnUpgrade(totalDocsCountUpgraded, modelId, TEXT_UPGRADED);
deletePipeline(PIPELINE_NAME);
deleteModel(modelId);
deleteIndex(testIndex);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"refresh_interval": "30s",
"default_pipeline": "%s"
},
"number_of_shards": 1,
"number_of_replicas": 0
"number_of_shards": 6,
"number_of_replicas": 2
},
"mappings": {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,11 @@ protected void waitForClusterHealthGreen(String numOfNodes) throws IOException {

/**
* Add a single Doc to an index
*
* @param index name of the index
* @param docId
* @param fieldName name of the field
* @param text to be added
*/
protected void addDocument(String index, String docId, String fieldName, String text) throws IOException {
Request request = new Request("PUT", "/" + index + "/_doc/" + docId + "?refresh=true");
Expand All @@ -843,6 +848,7 @@ protected void addDocument(String index, String docId, String fieldName, String

/**
* Get ingest pipeline
* @param pipelineName of the ingest pipeline
*/
@SneakyThrows
protected Map<String, Object> getIngestionPipeline(String pipelineName) {
Expand All @@ -854,6 +860,21 @@ protected Map<String, Object> getIngestionPipeline(String pipelineName) {
return (Map<String, Object>) responseMap.get(pipelineName);
}

/**
* Delete pipeline
*
* @param pipelineName of the pipeline
*/
@SneakyThrows
protected Map<String, Object> deletePipeline(String pipelineName) {
Request request = new Request("DELETE", "/_ingest/pipeline/" + pipelineName);
Response response = client().performRequest(request);
assertEquals(request.getEndpoint() + ": failed", RestStatus.OK, RestStatus.fromCode(response.getStatusLine().getStatusCode()));
String responseBody = EntityUtils.toString(response.getEntity());
Map<String, Object> responseMap = createParser(XContentType.JSON.xContent(), responseBody).map();
return responseMap;
}

/**
* Enumeration for types of pipeline processors, used to lookup resources like create
* processor request as those are type specific
Expand Down

0 comments on commit de02df2

Please sign in to comment.