Skip to content

Sort order results are not sorted properly #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michelson opened this issue Jul 12, 2016 · 2 comments
Closed

Sort order results are not sorted properly #594

michelson opened this issue Jul 12, 2016 · 2 comments
Labels

Comments

@michelson
Copy link

michelson commented Jul 12, 2016

Hi , I'm trying to sort by name, but I'm not getting the results properly sorted, I would like to know if anyone here got any ideas what is going on. the field I'm trying to sort is not_analyzed ,

the query is:

{:sort=>[{"name.raw"=>{"order"=>"asc"}}, "_doc"],
 :query=>
  {:filtered=>
    {:filter=>
      {:bool=>
        {:must=>
          [{:term=>{:account_id=>1}},
           {:bool=>{:should=>[], :minimum_should_match=>0}}],
         :must_not=>{:term=>{:state=>"deleted"}},
         :should=>[]}}}}}

when I get results the order is not right, if I inspect the sort attribute when I search results (not records) with Device.__elasticsearch__.search(query).results.map{|o| o["sort"]} I get something like this:

[["Mic233", 1], ["Mich-MacBook-Pro", 0], ["Mich-MacBook-Pro", 10], ["juanito", 4], ["juanito", 5], ["juanito", 6], ["juanito", 8], ["mbair", 17], ["motorola XT1058", 15], ["my XT1058", 11]]

I've mapped the field as not_analyzed

      indexes :name, type: 'multi_field' do
        indexes :name, type: :string
        indexes :raw, index: :not_analyzed
      end
@jogaco
Copy link

jogaco commented Jul 22, 2016

The results are perfectly fine to me. They are sorted in ASCII then _doc. Uppercase codes go first than lowercase.

@stale
Copy link

stale bot commented Aug 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 31, 2020
@stale stale bot closed this as completed Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants