Elasticsearch Version: 6.3.2
Kibana Version: 6.3.2
I've been using search templates for a while now and they've worked fine. Although when I _search/template
with a template I have (below), i get the following error:
"Unexpected character ('\"' (code 34)): was expecting comma to separate Object entries\n at [Source: java.io.StringReader@2359f61; line: 1, column: 1690]"
However when I render the template and copy the query and just use _search
it works perfectly. If anyone has any idea what I'm doing wrong it would be much help.
Template:
{
"aggregations": {
"top_hits_sampled": {
"aggregations": {
"top_retailer_hits": {
"top_hits": {
"from": {{from}},
"size": 50
}
}
},
"diversified_sampler": {
"field": "name",
"max_docs_per_value": 6,
"shard_size": 500
}
}
},
"query": {
"bool": {
"must": [
{{#keywords}}
{
"dis_max": {
"queries": [
{
"common": {
"title": {
"boost": 3,
"cutoff_frequency": 0.05,
"high_freq_operator": "or",
"low_freq_operator": "or",
"minimum_should_match": {
"high_freq": "50%",
"low_freq": "2<-1 4<-2 9<-3"
},
"query": "{{keywords}}"
}
}
},
{
"common": {
"description": {
"boost": 0.3,
"cutoff_frequency": 0.15,
"minimum_should_match": {
"high_freq": "100%",
"low_freq": "3<-1 5<-2 9<-3"
},
"query": "{{keywords}}"
}
}
},
{
"multi_match": {
"boost": 1,
"fields": [
"identifiers.*"
],
"max_expansions": 1,
"prefix_length": 8,
"query": "{{keywords}}"
}
},
{
"match": {
"categories.name": {
"boost": 2,
"query": "{{keywords}}"
}
}
}
],
"tie_breaker": 0.3
}
}
{{/keywords}}
],
"should": [
{{#toJson}}
splitKeywords
,
{{/toJson}}
{{#toJson}}
negativeMatch
{{/toJson}}
]
{{#filter}}
"filter": [
{{#range}}
{
"range": {{#toJson}}range{{/toJson}}
}
{{/range}}
{{#bool}}
,
{
"bool": {{#toJson}}bool{{/toJson}}
}
{{/bool}}
]
{{/filter}}
}
},
"size": 0
}
Params:
{
"id": "products_test",
"params": {
"from": 0,
"keywords": "ipad",
"negativeMatch": {
"bool": {
"minimum_should_match": "1",
"boost": 0.2,
"should": [
{
"term": {
"title": "book"
}
},
{
"term": {
"categories.name": "book"
}
},
{
"term": {
"title": "cover"
}
},
{
"term": {
"categories.name": "cover"
}
},
{
"term": {
"title": "case"
}
},
{
"term": {
"categories.name": "case"
}
},
{
"term": {
"title": "pouch"
}
},
{
"term": {
"categories.name": "pouch"
}
},
{
"term": {
"title": "stand"
}
},
{
"term": {
"categories.name": "stand"
}
},
{
"term": {
"title": "guide"
}
},
{
"term": {
"categories.name": "guide"
}
},
{
"term": {
"title": "ebook"
}
},
{
"term": {
"categories.name": "ebook"
}
},
{
"term": {
"title": "dvd"
}
},
{
"term": {
"categories.name": "dvd"
}
},
{
"term": {
"title": "cd"
}
},
{
"term": {
"categories.name": "cd"
}
},
{
"term": {
"title": "accessory"
}
},
{
"term": {
"categories.name": "accessory"
}
},
{
"term": {
"title": "movie"
}
},
{
"term": {
"categories.name": "movie"
}
},
{
"term": {
"title": "film"
}
},
{
"term": {
"categories.name": "film"
}
},
{
"term": {
"title": "paperback"
}
},
{
"term": {
"categories.name": "paperback"
}
}
]
}
},
"filter": {
"range": {
"offers.pricing.price.value": {
"lte": 6000
}
},
"bool": {
"should": [
{
"term": {
"name": "Something"
}
}
]
}
}
}
}