This function will Index indexData to be used by search API's unit test,PUT
call to the endpoint /api/"+indexName+"/_doc
with indexData in body.
-
This unit test will search documents with no existing Index:
POST
call to the endpoint/es/notExistSearch/_search
with{}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusBadRequest (i.e 400) , that means test is OK.
-
This unit test will search documents with existing Index:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match_all":{}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
-
This unit test will search document with no existing Term:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match": {"_all": "xxxx"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.Equal to check that total hit values are euqal to zero.
-
This unit test will search document with existing Term:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match": {"_all": "DEMTSCHENKO"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type match all:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match_all": {}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type wildcard:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"wildcard": {"_all": "dem*"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type fuzzy:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"fuzzy": {"Athlete": "demtschenk"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type term:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"term": {"City": "turin"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type data range:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"range": {"@timestamp": { "gte": "%s", "lt": "%s"}}}, "size":10}
in body withlt
as now() andgte
24 hours before thelt
.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type match:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match": {"_all": "DEMTSCHENKO"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type match phrase:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"match_phrase": {"_all": "DEMTSCHENKO"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type prefix:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"prefix": {"_all": "dem"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.
-
This unit test will search document with search type prefix:
POST
call to the endpoint/es/"+indexName+"/_search
with{"query": {"query_string": {"query": "DEMTSCHENKO"}}, "size":10}
in body.- Send the request to the server and response would be recorded.
- Using assert.Equal to check the response code is euqal to http.StatusOk (i.e 200) , that means test is OK.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.GreaterorEqual to check that total hit values are greater or equal to 1.