No highlights with function_score query


(vinamar) #1

The ES is not returning highlights for the given function_score query below on Elasticsearch 0.90.7

{
"facets": {
"histo": {
"date_histogram": {
"field": "closeDt",
"interval": "1h"
}
},
"channel": {
"terms": {
"field": "channel"
}
},
"siteId": {
"terms": {
"field": "siteId"
}
},
"domains.L1.domain.id": {
"terms": {
"field": "domains.L1.domain.id"
}
}
},
"query": {
"query_string": {
"query": "payment",
"default_operator": "AND",
"fields": [
[
"emails.emailBody",
"srId",
"chatTextArray.text"
]
]
},
"filtered": {
"filter": {
"and": [
{
"term": {
"domains.L1.domain.id": "2"
}
},
{
"range": {
"closeDt": {
"from": 1325404800000,
"to": 1386835200000
}
}
}
]
}
},
"function_score": {
"functions": [
{
"script_score": {
"script": "_score*_source._boost*doc['domains.L1.domain.2.prob'].value"
}
}
]
}
},
"highlight": {
"pre_tags": [
""
],
"post_tags": [
"
"
],
"fields": {
"srId": {
"number_of_fragments": 0
},
"emails.emailBody": {
"number_of_fragments": 0
},
"chatTextArray.text": {
"number_of_fragments": 0
}
}
}
}

i was expecting to receive highlights with the results.

thanks for your help!


(vinamar) #2

I tried with the following query it returns highlights, but term filter is not working.
On the other hand if i use {filtered:filter..} it applies the term filter correctly, but doesn't return the highlighted results.

{
"facets": {
"histo": {
"date_histogram": {
"field": "closeDt",
"interval": "1h"
}
},
"channel": {
"terms": {
"field": "channel"
}
},
"siteId": {
"terms": {
"field": "siteId"
}
},
"domains.L1.domain.id": {
"terms": {
"field": "domains.L1.domain.id"
}
}
},
"query": {
"function_score": {
"query": {
"query_string": {
"query": "payment",
"default_operator": "AND",
"fields": [
[
"emails.emailBody",
"srId",
"chatTextArray.text"
]
]
}
},
"functions": [
{
"filter": {
"and": [
{
"term": {
"domains.L1.domain.id": "2"
}
},
{
"range": {
"closeDt": {
"from": 1325404800000,
"to": 1386835200000
}
}
}
]
},
"script_score": {
"script": "_score*_source._boost*doc['domains.L1.domain.2.prob'].value"
}
}
]
}
},
"highlight": {
"pre_tags": [
""
],
"post_tags": [
"
"
],
"fields": {
"srId": {
"number_of_fragments": 0
},
"emails.emailBody": {
"number_of_fragments": 0
},
"chatTextArray.text": {
"number_of_fragments": 0
}
}
},
"timeout": 30000
}


(system) #3