Sorting issue with space

After Sort I am getting result like this

Adfgsdh
Bhdfaf
Dbsdf
Z Edfghf
Mkjldfhd
Zdhgj

Word Z Edfghf came on wrong place. When I removed space it came on proper place

ElasticsearchResponse objElasticResponse = objClient.Search(strIndex, strType, @"
{
""from"": 0,
""size"": 10000,
""sort"" :[
{ ""Name"": { ""order"" : ""asc"" , ""missing"" : ""_last"" , ""unmapped_type"" : ""long""} }
],
""query"": {
""bool"": {
""must"": [
],
""should"":[
]
}
}
}");

What's the mapping on the field?

"Name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"fielddata" : true
}

Use the Name.keyword field and you should be ok.

ElasticsearchResponse objElasticResponse = objClient.Search(strIndex, strType, @"
{
""from"": 0,
""size"": 10000,
""sort"" :[
{ ""Name.keyword"": { ""order"" : ""asc"" , ""missing"" : ""_last"" , ""unmapped_type"" : ""long""} }
],
""query"": {
""bool"": {
""must"": [
],
""should"":[
]
}
}
}");

Query like this

Hi.

Sorting is still not coming as expected

AbcEdf
Abc Zgdfg

if sort above, Second word is coming first because of that space

Hi.

Sorting is still not coming as expected

AbcEdf
Abc Zgdfg

if sort above, Second word is coming first because of that space

That is as far as I can see the correct and expected ASCII sorting order. I am not sure if it is possible to override this.

Ok. Anyway Thanks Christian_Dahlqvist.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.