Skip to content

Instantly share code, notes, and snippets.

@mrvisser
Created October 25, 2012 00:43
Show Gist options
  • Save mrvisser/3949834 to your computer and use it in GitHub Desktop.
Save mrvisser/3949834 to your computer and use it in GitHub Desktop.
Sort field tokenized
// Query:
{
"query": {
"query_string": {
"default_field": "general",
"query": "*"
}
},
"from": "0",
"size": "10",
"sort": {
"sort": "asc"
}
}
// Schema:
{
'tenantId': { 'type': 'string', 'store': 'no', 'index': 'not_analyzed' },
'name': { 'type': 'string', 'store': 'yes', 'index': 'no' },
'description': { 'type': 'string', 'store': 'yes', 'index': 'no' },
'visibility': { 'type': 'string', 'store': 'yes', 'index': 'not_analyzed' },
'general': { 'type': 'string', 'store': 'no', 'index': 'analyzed' },
'sort': { 'type': 'string', 'store': 'no', 'index': 'not_analyzed' },
'access': {
'properties': {
'principalId': { 'type': 'string', 'store': 'no', 'index': 'not_analyzed' }
}
}
}
// Error:
data: {
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[aiDFbmCjQWukWq5G9vF21g][oae][0]: QueryPhaseExecutionException[[oae][0]: query[ConstantScore(NotDeleted(*:*))],from[0],size[10],sort[<custom:\"sort\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@2f5a0e96>]: Query Failed [Failed to execute main query]]; nested: IOException[Can't sort on string types with more than one value per doc, or more than one token per field]; }]",
"status": 500
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment