Narmatha
(Narmatha)
September 5, 2017, 11:09am
1
I have an index with a long field and i am just trying to use search template to use terms query but it throws exception.
"pid": {
"type": "long"
}
Search Template: PUT /_search/template/article_query_template
{
"template": {
"query": {
"terms": {
"pid": "{{articleId}}"
}
}
}
}
Search Query :
POST test2*/_search
{
"query": {
"template": {
"id": "article_query_template",
"params" : {
"articleId" : [1, 2]
}
}
}
}
Exception : reason": "[terms] query does not support [pid]".
Its working without template. How to fix this issue.
jpountz
(Adrien Grand)
September 6, 2017, 5:06pm
2
Since you are passing a json array, you need to escape it:
GET _search/template
{
"template": """{
"query": {
"terms": {
"pid": {{#toJson}}articleId{{/toJson}}
}
}
}""",
"params": {
"articleId": [
1,
2
]
}
}
Narmatha
(Narmatha)
September 7, 2017, 9:29am
3
It shows error without quotes {{#toJson }}articleId{{/toJson}}.
Also array search thows exception "reason": "For input string: ""articleId""".
The field is of type long.
system
(system)
Closed
October 5, 2017, 9:30am
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.