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/api/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/api/"+indexName+"/_search
with{"search_type": "alldocuments"}
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/api/"+indexName+"/_search
with{"search_type": "match", "query": {"term": "hello"}}
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/api/"+indexName+"/_search
with{"search_type": "match", "query": {"term": "DEMTSCHENKO"}}
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 all documents:
POST
call to the endpoint/api/"+indexName+"/_search
with{"search_type": "alldocuments", "query": {}}
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/api/"+indexName+"/_search
with{"search_type": "wildcard", "query": {"term": "dem*"}}
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/api/"+indexName+"/_search
with{"search_type": "fuzzy", "query": {"term": "demtschenk"}}
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/api/"+indexName+"/_search
with{"search_type": "term","query": {"term": "turin","field":"City"}}
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/api/"+indexName+"/_search
with{"search_type": "daterange","query": {"start_time": "%s","end_time": "%s"}}
in body withend_time
as now() andstart_time
24 hours before theend_time
.- 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/api/"+indexName+"/_search
with{"search_type": "matchall", "query": {"term": "demtschenk"}}
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:
POST
call to the endpoint/api/"+indexName+"/_search
with{"search_type": "match", "query": {"term": "DEMTSCHENKO"}}
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/api/"+indexName+"/_search
with{"search_type": "matchphrase", "query": {"term": "DEMTSCHENKO"}}
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 multi phrase:
POST
call to the endpoint/api/"+indexName+"/_search
with{"search_type": "multiphrase","query": {"terms": [["demtschenko"],["albert"]]}}
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/api/"+indexName+"/_search
with{"search_type": "prefix", "query": {"term": "dem"}}
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/api/"+indexName+"/_search
with{"search_type": "querystring", "query": {"term": "DEMTSCHENKO"}}
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.