Solr raises an error when a dimension value code is a reserved keyword
Sometimes dimension value codes match Solr reserved words (e.g. AND
, NOT
, etc).
Example: the dataset IMF/WEO:2022-04
has country=AND
(Andorra).
The corresponding API link responds a server error, and the logger error (Solr response to the API) is:
{
error: {
code: 400,
metadata: [
'error-class',
'org.apache.solr.common.SolrException',
'root-error-class',
'org.apache.solr.parser.ParseException'
],
msg: 'org.apache.solr.search.SyntaxError: Cannot parse \'dimension_value_code.weo-country:AND\': Encountered " <AND> "AND "" at line 1, column 33.\nWas expecting one of:\n <BAREOPER> ...\n "(" ...\n "*" ...\n <QUOTED> ...\n <TERM> ...\n <PREFIXTERM> ...\n <WILDTERM> ...\n <REGEXPTERM> ...\n "[" ...\n "{" ...\n <LPARAMS> ...\n "filter(" ...\n <NUMBER> ...\n '
},
responseHeader: {
params: {
json: '{"query": "provider_code:IMF AND dataset_code:WEO\\\\:2022\\\\-04", "filter": ["type:series", "{!tag=DIMENSION.weo-country}dimension_value_code.weo-country:AND"], "facet": {"dimension.weo-country": {"type": "terms", "field": "dimension_value_code.weo-country", "limit": -1, "mincount": 1, "domain": {"excludeTags": "DIMENSION.weo-country"}}, "dimension.weo-su...
},
QTime: 0
}
}
Cf Sentry issue
Edited by Christophe Benz