Index mapping:
{
"index":
{
"mappings":
{
"dynamic": "strict",
"_source":
{
"excludes":
[
"patientClaims"
]
},
"properties":
{
"patientClaims":
{
"properties":
{
"diagnosisIcdCode": {
"type": "keyword"
},
"diversity":
{
"type": "keyword"
}
}
}
}
}
}
}
Query:
{
"from": 0,
"size": 20,
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"function_score": {
"query": {
"has_child": {
"type": "claim",
"score_mode": "sum",
"query": {
"function_score": {
"query": {
"bool": {
"filter": [
{
"terms": {
"patientClaims.diagnosisIcdCode": [
"E7021"
]
}
}
]
}
},
"functions": [
{
"script_score": {
"script": "doc['patientClaims.diversity'].size()==0 ? 0 : (doc['patientClaims.diversity'].value == 'White Non-Hispanic' ? 0 : 1)"
}
}
]
}
},
"inner_hits":
{
"name": "patient_claims_matching_count",
"size": 0,
"_source": false
}
}
}
}
}
]
}
}
}
}
}
Top score is zero, nothing matches. Can we not use those fields which are excluded from _source
in scrip score?