Hi All,
Am having the data with mappings as shown:
"ymme_type": {
"_all": {
"auto_boost": true,
"index_analyzer": "wordAnalyzer",
"search_analyzer": "whitespace_analyzer"
},
"properties": {
"Engine": {
"type": "string",
"index": "not_analyzed"
},
"EngineCode": {
"type": "string",
"include_in_all": false
},
"Make": {
"type": "string",
"boost": 3,
"index": "not_analyzed",
"norms": {
"enabled": true
}
},
"MakeCode": {
"type": "string",
"include_in_all": false
},
"Model": {
"type": "string",
"boost": 2,
"index": "not_analyzed",
"norms": {
"enabled": true
}
},
"ModelCode": {
"type": "string",
"include_in_all": false
},
"ShortYear": {
"type": "string",
"boost": 4,
"index": "not_analyzed",
"norms": {
"enabled": true
}
},
"Year": {
"type": "string",
"boost": 5,
"index": "not_analyzed",
"norms": {
"enabled": true
},
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"YearCode": {
"type": "string",
"include_in_all": false
}
}
}
And the relevant analyzers are as shown:
"analysis": {
"analyzer": {
"analyzer_startswith": {
"type": "custom",
"filter": "lowercase",
"tokenizer": "keyword"
},
"whitespace_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "whitespace"
},
"wordAnalyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
],
"tokenizer": "whitespace"
}
},
"filter": {
"nGram_filter": {
"max_gram": "20",
"min_gram": "1",
"type": "nGram",
"token_chars": [
"letter",
"punctuation",
"symbol",
"digit"
]
}
}
}
I would like to keep the scripting to particular fields and I have used the following query:
GET ymme/ymme_type/_search
{
"query": {
"match": {
"_all":
{
"query": "2012",
"operator": "and"
}
}
},
"script_fields": {
"year_script": {
"script": "doc['Year'].value*2"
}
}
}
It is throwing the following Exception:
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[jlllRXEgTlKVYQa7rLvLNw][ymme][0]: SearchParseException[[ymme][0]: query[_all:2012],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "match": {\n "_all": \n {\n "query": "2012",\n "operator": "and"\n }\n }\n },\n "script_fields": {\n "year_script": {\n "script": "doc['Year'].value2"\n }\n }\n}\n]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[jlllRXEgTlKVYQa7rLvLNw][ymme][1]: SearchParseException[[ymme][1]: query[_all:2012],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "match": {\n "_all": \n {\n "query": "2012",\n "operator": "and"\n }\n }\n },\n "script_fields": {\n "year_script": {\n "script": "doc['Year'].value2"\n }\n }\n}\n]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[jlllRXEgTlKVYQa7rLvLNw][ymme][2]: SearchParseException[[ymme][2]: query[_all:2012],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "match": {\n "_all": \n {\n "query": "2012",\n "operator": "and"\n }\n }\n },\n "script_fields": {\n "year_script": {\n "script": "doc['Year'].value2"\n }\n }\n}\n]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[jlllRXEgTlKVYQa7rLvLNw][ymme][3]: SearchParseException[[ymme][3]: query[_all:2012],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "match": {\n "_all": \n {\n "query": "2012",\n "operator": "and"\n }\n }\n },\n "script_fields": {\n "year_script": {\n "script": "doc['Year'].value2"\n }\n }\n}\n]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }{[jlllRXEgTlKVYQa7rLvLNw][ymme][4]: SearchParseException[[ymme][4]: query[_all:2012],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "match": {\n "_all": \n {\n "query": "2012",\n "operator": "and"\n }\n }\n },\n "script_fields": {\n "year_script": {\n "script": "doc['Year'].value*2"\n }\n }\n}\n]]]; nested: ScriptException[dynamic scripting for [groovy] disabled]; }]",
"status": 400
May I know what is the reason??????, my intention is to get the response based on the scripting that I have used but not based on the default Lucene Score ..