I'm trying to create a custom analyzer that does the following: if a token length is greater than 14, include the token itself as well as the truncated token:
PUT localhost:9200/assets/
{
"settings": {
"analysis": {
"analyzer": {
"tokens_greater_14_analyzer": {
"tokenizer": "standard",
"filter": [ "greater_than_14_chars" ]
}
},
"filter": {
"greater_than_14_chars": {
"type": "condition",
"filter": ["trunc_and_original"],
"script": {
"source": "token.getTerm().length() > 14"
}
},
"trunc_and_original": {
"type": "multiplexer",
"filters": ["lowercase", ["lowercase, trunc_14_chars"]]
},
"trunc_14_chars": {
"type": "truncate",
"length": 14
}
}
}
}
}
But when making that API call, I get the following error:
{
"error": {
"root_cause": [
{
"type": "settings_exception",
"reason": "Failed to load settings from [{\"analysis\":{\"filter\":{\"trunc_14_chars\":{\"length\":14,\"type\":\"truncate\"},\"greater_than_14_chars\":{\"filter\":[\"trunc_and_original\"],\"type\":\"condition\",\"script\":{\"source\":\"token.getTerm().length() > 14\"}},\"trunc_and_original\":{\"filters\":[\"lowercase\",[\"lowercase, trunc_14_chars\"]],\"type\":\"multiplexer\"}},\"analyzer\":{\"tokens_greater_14_analyzer\":{\"filter\":[\"greater_than_14_chars\"],\"tokenizer\":\"standard\"}}}}]"
}
],
"type": "settings_exception",
"reason": "Failed to load settings from [{\"analysis\":{\"filter\":{\"trunc_14_chars\":{\"length\":14,\"type\":\"truncate\"},\"greater_than_14_chars\":{\"filter\":[\"trunc_and_original\"],\"type\":\"condition\",\"script\":{\"source\":\"token.getTerm().length() > 14\"}},\"trunc_and_original\":{\"filters\":[\"lowercase\",[\"lowercase, trunc_14_chars\"]],\"type\":\"multiplexer\"}},\"analyzer\":{\"tokens_greater_14_analyzer\":{\"filter\":[\"greater_than_14_chars\"],\"tokenizer\":\"standard\"}}}}]",
"caused_by": {
"type": "illegal_state_exception",
"reason": "only value lists are allowed in serialized settings"
}
},
"status": 500
}
Any help would be appreciated. Thanks!