203cd69dcb
add new action specific parameter esversion.major resolves: rhbz#2209017
54 lines
2.3 KiB
Diff
54 lines
2.3 KiB
Diff
diff --git a/plugins/omelasticsearch/omelasticsearch.c b/plugins/omelasticsearch/omelasticsearch.c
|
|
index f481ec3f7e..b297a9274f 100644
|
|
--- a/plugins/omelasticsearch/omelasticsearch.c
|
|
+++ b/plugins/omelasticsearch/omelasticsearch.c
|
|
@@ -623,7 +623,7 @@ setPostURL(wrkrInstanceData_t *const pWrkrData, uchar **const tpls)
|
|
/* since 7.0, the API always requires /idx/_doc, so use that if searchType is not explicitly set */
|
|
uchar* actualSearchType = (uchar*)"_doc";
|
|
es_str_t *url;
|
|
- int r;
|
|
+ int r = 0;
|
|
DEFiRet;
|
|
instanceData *const pData = pWrkrData->pData;
|
|
char separator;
|
|
@@ -646,13 +646,12 @@ setPostURL(wrkrInstanceData_t *const pWrkrData, uchar **const tpls)
|
|
getIndexTypeAndParent(pData, tpls, &searchIndex, &searchType, &parent, &bulkId, &pipelineName);
|
|
if(searchIndex != NULL) {
|
|
r = es_addBuf(&url, (char*)searchIndex, ustrlen(searchIndex));
|
|
+ if(searchType != NULL && searchType[0] != '\0') {
|
|
+ actualSearchType = searchType;
|
|
+ }
|
|
if(r == 0) r = es_addChar(&url, '/');
|
|
-
|
|
- if(searchType != NULL) {
|
|
- actualSearchType = searchType;
|
|
+ if(r == 0) r = es_addBuf(&url, (char*)actualSearchType, ustrlen(actualSearchType));
|
|
}
|
|
- if(r == 0) r = es_addChar(&url, '/');
|
|
- if(r == 0) r = es_addBuf(&url, (char*)actualSearchType, ustrlen(actualSearchType));
|
|
if(pipelineName != NULL && (!pData->skipPipelineIfEmpty || pipelineName[0] != '\0')) {
|
|
if(r == 0) r = es_addChar(&url, separator);
|
|
if(r == 0) r = es_addBuf(&url, "pipeline=", sizeof("pipeline=")-1);
|
|
@@ -714,7 +713,11 @@ computeMessageSize(const wrkrInstanceData_t *const pWrkrData,
|
|
r += ustrlen(searchIndex);
|
|
}
|
|
if(searchType != NULL) {
|
|
- r += ustrlen(searchType);
|
|
+ if(searchType[0] == '\0') {
|
|
+ r += 4; // "_doc"
|
|
+ } else {
|
|
+ r += ustrlen(searchType);
|
|
+ }
|
|
}
|
|
if(parent != NULL) {
|
|
r += sizeof(META_PARENT)-1 + ustrlen(parent);
|
|
@@ -759,7 +762,7 @@ buildBatch(wrkrInstanceData_t *pWrkrData, uchar *message, uchar **tpls)
|
|
if(r == 0) r = es_addBuf(&pWrkrData->batch.data, META_IX, sizeof(META_IX)-1);
|
|
if(r == 0) r = es_addBuf(&pWrkrData->batch.data, (char*)searchIndex,
|
|
ustrlen(searchIndex));
|
|
- if(searchType != NULL) {
|
|
+ if(searchType != NULL && searchType[0] != '\0') {
|
|
if(r == 0) r = es_addBuf(&pWrkrData->batch.data, META_TYPE, sizeof(META_TYPE)-1);
|
|
if(r == 0) r = es_addBuf(&pWrkrData->batch.data, (char*)searchType,
|
|
ustrlen(searchType));
|