No field found in mapping while executing custom score script

I've been struggling with this issue for hours now. I am trying to implement custom score in my search using script score (groovy).

Mapping :

{
"properties": {
    "m_skill": {
        "properties": {
            "actual_period": {
                "type": "long"
            },
            "area_display": {
                "type": "string"
            },
            "c": {
                "type": "double"
            },
            "capability": {
                "type": "string"
            },
            "capability_display": {
                "type": "string"
            },
            "order_wt": {
                "type": "double"
            },
            "skillarea": {
                "type": "string"
            },
            "star_wt": {
                "type": "double"
            },
            "w": {
                "type": "double"
            }
            }
        }
    },
    "personid": {
		"type": "string"
	},
    date_of_creation": {
		"type": "long"
	},
    "phone": {
		"properties": {
			"c": {
				"type": "long"
			},
			"v": {
				"type": "string"
			}
		}
	}
}

(m_skill is an array)

Query :

{"match_all":{}}

Score script :

return doc['m_skill'].values.star_wt.sum()

Error :

No field found for [m_skill] in mapping with types [peopleworld]

But I don't get any exception when I try the same with "date_of_creation".
I found some people talking about the same issue but hardly any post has replies. Has anyone faced an issue like this. What am I doing wrong?

Another question, my formula is way complex then I wrote above. In simple language, it is like when a user asks for a set of skills I pick documents having asked skills and depending on their star_wt I award them a score which is used to sort the final result set. Is it a good idea to implementing the same using elasticsearch custom score?

Any help will be much welcomed.

Hey,

a full reproduction (including index creation, document creation, query with the full groovy scripts), would help here.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.