Hi,
I can't for the life of me figure out how you can restrict what fields are returned when using a search template. I have the following template.
"template": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "{{useCase}}",
"boost": 0.5
}
}
},
{
"boosting": {
"positive": {
"match": {
"label_names": {
"query": "{{label}}",
"boost": 0.75,
"analyzer": "camel_analyzer"
}
}
},
"negative": {
"match": {
"label_names": "device, device info, device information"
}
},
"negative_boost": 1
}
},
{
"match": {
"body": {
"query": "{{useCase}}",
"boost": 0.5
}
}
}
]
}
}
}
}
}
So most of my searching refers to this syntax
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html
It seems like adding the field to usage request would be the logical place so that you could at run time control what you want to return.
GET myindex/_search/template
{
"fields" : ["title", "label_names"],
"id": "articles",
"params": {
"useCase": "my search string",
"label": "label"
}
}
but fields its not allowed here, nor is it allowed in the template above the query sections. which is very confusing because based on the docs it seems a like you should be able to stick it there but it seems like query in a template is not a real query.