I am using the below gradle implementation 'co.elastic.clients:elasticsearch-java:8.1.0'
I am having a script posted in elasticsearch as below
{
"script": {
"lang": "mustache",
"source": {
"suggest": {
"text": "{{query_string}}",
"simple_phrase": {
"phrase": {
"field": "title.completion",
"size": 1,
"direct_generator": [
{
"field": "title.completion",
"size": 4,
"suggest_mode": "popular",
"max_edits": 1,
"prefix_length": 3
}
],
"collate": {
"query": {
"source": {
"match": {
"{{field_name}}": "{{suggestion}}"
}
}
},
"params": {
"field_name": "title"
},
"prune": true
}
}
}
}
},
"params": {
"query_string": "My query string"
}
}
}
When i run the above suggestor i get results as below:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"suggest": {
"simple_phrase": [
{
"text": "abd",
"offset": 0,
"length": 6,
"options": [
{
"text": "abc",
"score": 0.0018216542,
"collate_match": true
}
]
}
]
}
}
I am using the below code to do a template search
SearchTemplateRequest request = new SearchTemplateRequest.Builder()
.index(index)
.id("xyz")
.params("query_string", JsonData.of(queryName))
.build();
SearchTemplateResponse searchTemplateResponse = elasticNewSearchClient.searchTemplate(request, MyElasticSearchIndexFieldsClassSerialized.class);
MyElasticSearchIndexFieldsClassSerialized class contains all the fields of the index and it implements Serialized
When i am running this, i am getting the below error
Method threw co.elastic.clients.json.UnexpectedJsonEventException Exception