How to sort with standard alphabe

I need sort order title like

  1. "AAA"
  2. "aaa"
  3. "BBB"
  4. "bbb"
  5. "CCC"
  6. "ccc"
    but in Elastic search when I use this query
    {
    "fields": [
    "title"
    ],
    "query": {
    "query_string": {
    "query": "*",
    "fields": [
    "title"
    ]
    }
    },
    "sort": [
    {
    "title.untouched": "asc" // title is multi_field
    }
    ]
    }
    The result allways
  7. "AAA"
  8. "BBB"
  9. "CCC"
  10. "aaa"
  11. "bbb"
  12. "ccc"
    It's not correct. Help me please.
    I use the analysis
    "settings":{
    "index" : {
    "analysis" : {
    "analyzer" : {
    "index_analyzer" : {
    "tokenizer" : "keyword",
    "filter" : ["icu_collation"]
    }
    }
    }
    }
    }

But the order doesn't run like me want.

You can try using script-based sorting, where the value to sort on is
the lower-cased field.

On Wed, Mar 14, 2012 at 3:54 AM, inlier hiquocthang@gmail.com wrote:

I need sort order title like

  1. "AAA"
  2. "aaa"
  3. "BBB"
  4. "bbb"
  5. "CCC"
  6. "ccc"
    but in Elastic search when I use this query
    {
    "fields": [
    "title"
    ],
    "query": {
    "query_string": {
    "query": "*",
    "fields": [
    "title"
    ]
    }
    },
    "sort": [
    {
    "title.untouched": "asc" // title is multi_field
    }
    ]
    }
    The result allways
  7. "AAA"
  8. "BBB"
  9. "CCC"
  10. "aaa"
  11. "bbb"
  12. "ccc"
    It's not correct. Help me please.
    I use the analysis
    "settings":{
    "index" : {
    "analysis" : {
    "analyzer" : {
    "index_analyzer" : {
    "tokenizer" : "keyword",
    "filter" : ["icu_collation"]
    }
    }
    }
    }
    }

But the order doesn't run like me want.

Please explain more. I TRY with this query but it can't run, I think
because doc['title'].value is not number.
{
"fields": [
"title"
],
"query": {
"query_string": {
"query": "*",
"default_operator": "AND",
"fields": [
"title"
]
}
},
"sort": {
"_script": {
"script": "doc['title'].value * factor",
"type": "number",
"params": {
"factor": 1.1
}
}
}
}

On Mar 15, 12:02 am, Ivan Brusic i...@brusic.com wrote:

You can try using script-based sorting, where the value to sort on is
the lower-cased field.

Elasticsearch Platform — Find real-time answers at scale | Elastic

On Wed, Mar 14, 2012 at 3:54 AM, inlier hiquocth...@gmail.com wrote:

I need sort order title like

  1. "AAA"
  2. "aaa"
  3. "BBB"
  4. "bbb"
  5. "CCC"
  6. "ccc"
    but in Elastic search when I use this query
    {
    "fields": [
    "title"
    ],
    "query": {
    "query_string": {
    "query": "*",
    "fields": [
    "title"
    ]
    }
    },
    "sort": [
    {
    "title.untouched": "asc" // title is multi_field
    }
    ]
    }
    The result allways
  7. "AAA"
  8. "BBB"
  9. "CCC"
  10. "aaa"
  11. "bbb"
  12. "ccc"
    It's not correct. Help me please.
    I use the analysis
    "settings":{
    "index" : {
    "analysis" : {
    "analyzer" : {
    "index_analyzer" : {
    "tokenizer" : "keyword",
    "filter" : ["icu_collation"]
    }
    }
    }
    }
    }

But the order doesn't run like me want.

Perhaps I was premature in suggesting scripts given that I have never
used them for sorting. I assumed they worked like facet scripts, where
they return the value to be used, but it appears that sorting scripts
return a numerical value to be sorted on.

I wonder would it be possible to have script like:
"sort": {
"_script": {
"script": "doc['title'].value.toLowerCase",
"type": "string",
}
}

Not sure if "string" is a supported type.

On Wed, Mar 14, 2012 at 7:26 PM, inlier hiquocthang@gmail.com wrote:

Please explain more. I TRY with this query but it can't run, I think
because doc['title'].value is not number.
{
"fields": [
"title"
],
"query": {
"query_string": {
"query": "*",
"default_operator": "AND",
"fields": [
"title"
]
}
},
"sort": {
"_script": {
"script": "doc['title'].value * factor",
"type": "number",
"params": {
"factor": 1.1
}
}
}
}

On Mar 15, 12:02 am, Ivan Brusic i...@brusic.com wrote:

You can try using script-based sorting, where the value to sort on is
the lower-cased field.

Elasticsearch Platform — Find real-time answers at scale | Elastic

On Wed, Mar 14, 2012 at 3:54 AM, inlier hiquocth...@gmail.com wrote:

I need sort order title like

  1. "AAA"
  2. "aaa"
  3. "BBB"
  4. "bbb"
  5. "CCC"
  6. "ccc"
    but in Elastic search when I use this query
    {
    "fields": [
    "title"
    ],
    "query": {
    "query_string": {
    "query": "*",
    "fields": [
    "title"
    ]
    }
    },
    "sort": [
    {
    "title.untouched": "asc" // title is multi_field
    }
    ]
    }
    The result allways
  7. "AAA"
  8. "BBB"
  9. "CCC"
  10. "aaa"
  11. "bbb"
  12. "ccc"
    It's not correct. Help me please.
    I use the analysis
    "settings":{
    "index" : {
    "analysis" : {
    "analyzer" : {
    "index_analyzer" : {
    "tokenizer" : "keyword",
    "filter" : ["icu_collation"]
    }
    }
    }
    }
    }

But the order doesn't run like me want.

Another option is to have the title indexed as multi field, once with a
keyword tokenizer and lowercase, and once just with keyword tokenizer (so
it retains the casing). Sorting can be done on the lowercase one, and
fetching the relevant actual non lowercased field can be done by simply
asking for it from results.

On Fri, Mar 16, 2012 at 7:29 PM, Ivan Brusic ivan@brusic.com wrote:

Perhaps I was premature in suggesting scripts given that I have never
used them for sorting. I assumed they worked like facet scripts, where
they return the value to be used, but it appears that sorting scripts
return a numerical value to be sorted on.

I wonder would it be possible to have script like:
"sort": {
"_script": {
"script": "doc['title'].value.toLowerCase",
"type": "string",
}
}

Not sure if "string" is a supported type.

On Wed, Mar 14, 2012 at 7:26 PM, inlier hiquocthang@gmail.com wrote:

Please explain more. I TRY with this query but it can't run, I think
because doc['title'].value is not number.
{
"fields": [
"title"
],
"query": {
"query_string": {
"query": "*",
"default_operator": "AND",
"fields": [
"title"
]
}
},
"sort": {
"_script": {
"script": "doc['title'].value * factor",
"type": "number",
"params": {
"factor": 1.1
}
}
}
}

On Mar 15, 12:02 am, Ivan Brusic i...@brusic.com wrote:

You can try using script-based sorting, where the value to sort on is
the lower-cased field.

Elasticsearch Platform — Find real-time answers at scale | Elastic

On Wed, Mar 14, 2012 at 3:54 AM, inlier hiquocth...@gmail.com wrote:

I need sort order title like

  1. "AAA"
  2. "aaa"
  3. "BBB"
  4. "bbb"
  5. "CCC"
  6. "ccc"
    but in Elastic search when I use this query
    {
    "fields": [
    "title"
    ],
    "query": {
    "query_string": {
    "query": "*",
    "fields": [
    "title"
    ]
    }
    },
    "sort": [
    {
    "title.untouched": "asc" // title is multi_field
    }
    ]
    }
    The result allways
  7. "AAA"
  8. "BBB"
  9. "CCC"
  10. "aaa"
  11. "bbb"
  12. "ccc"
    It's not correct. Help me please.
    I use the analysis
    "settings":{
    "index" : {
    "analysis" : {
    "analyzer" : {
    "index_analyzer" : {
    "tokenizer" : "keyword",
    "filter" : ["icu_collation"]
    }
    }
    }
    }
    }

But the order doesn't run like me want.

"analyzer" : {
"index_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},
"sort_analyzer" : {
"tokenizer" : "keyword"

                }
            }

I set multi field "title" for index_analyser and "title.untouched" for
"sort_analyzer" but this setting don't run like I want. It sorts by
aaa
AAA
bbb
BBB
( i don't want this).

To Ivan Brusic, thanks for helping me. I like your way, I can get more
when see your code, but it not run good for me.