Skip to content

Instantly share code, notes, and snippets.

@nherment
Created March 22, 2012 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nherment/2158124 to your computer and use it in GitHub Desktop.
Save nherment/2158124 to your computer and use it in GitHub Desktop.
elasticsearch issue: sort fail on not_analyzed attribute
{
"UILayout": {
"properties": {
"id": {
"store": "yes",
"type": "long"
},
"userId": {
"store": "yes",
"type": "string"
},
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
"key": {
"type": "string"
},
"layoutType": {
"store": "yes",
"type": "string"
},
"entityName": {
"store": "yes",
"type": "string"
},
"classIdentifier": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
}
}
}
}
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"query_string" : {"query" : "name:new*"}},"sort" : [{"name":"asc"}]}' http://localhost:9200/system/UILayout/_search?pretty=true
{
"took" : 28,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 2,
"failed" : 3,
"failures" : [ {
"index" : "system",
"shard" : 2,
"status" : 500,
"reason" : "QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)->FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:\"name\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@6f172517>]: 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]; "
}, {
"index" : "system",
"shard" : 4,
"status" : 500,
"reason" : "QueryPhaseExecutionException[[system][4]: query[filtered(name:new*)->FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:\"name\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@588441fb>]: 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]; "
}, {
"index" : "system",
"shard" : 1,
"status" : 500,
"reason" : "QueryPhaseExecutionException[[system][1]: query[filtered(name:new*)->FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:\"name\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@5307f323>]: 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]; "
} ]
},
"hits" : {
"total" : 5,
"max_score" : null,
"hits" : [ {
"_index" : "system",
"_type" : "UILayout",
"_id" : "new1",
"_score" : null, "_source" : {"key":"new1","name":"new1","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96592},
"sort" : [ "new1" ]
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newC",
"_score" : null, "_source" : {"key":"newC","name":"newC","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96604},
"sort" : [ "newC" ]
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newE",
"_score" : null, "_source" : {"key":"newE","name":"newE","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96612},
"sort" : [ "newE" ]
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newH",
"_score" : null, "_source" : {"key":"newH","name":"newH","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96624},
"sort" : [ "newH" ]
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newJ",
"_score" : null, "_source" : {"key":"newJ","name":"newJ","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96632},
"sort" : [ "newJ" ]
} ]
}
}
curl -XPOST -d '{"from" : 0, "size" : 10, "query":{"query_string" : {"query" : "name:new*"}}}' http://localhost:9200/system/UILayout/_search?pretty=true
{
"took" : 57,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 13,
"max_score" : 1.0,
"hits" : [ {
"_index" : "system",
"_type" : "UILayout",
"_id" : "new1",
"_score" : 1.0, "_source" : {"key":"new1","name":"new1","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96592}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newE",
"_score" : 1.0, "_source" : {"key":"newE","name":"newE","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96612}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newJ",
"_score" : 1.0, "_source" : {"key":"newJ","name":"newJ","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96632}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newA",
"_score" : 1.0, "_source" : {"key":"newA","name":"newA","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96596}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newF",
"_score" : 1.0, "_source" : {"key":"newF","name":"newF","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96616}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newK",
"_score" : 1.0, "_source" : {"key":"newK","name":"newK","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96636}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newB",
"_score" : 1.0, "_source" : {"key":"newB","name":"newB","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96600}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newG",
"_score" : 1.0, "_source" : {"key":"newG","name":"newG","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96620}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newL",
"_score" : 1.0, "_source" : {"key":"newL","name":"newL","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96640}
}, {
"_index" : "system",
"_type" : "UILayout",
"_id" : "newC",
"_score" : 1.0, "_source" : {"key":"newC","name":"newC","classIdentifier":null,"entityName":null,"layoutType":"static_widget","userId":null,"id":96604}
} ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment