Skip to content

Sorting issue #217

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
paxer opened this issue Aug 25, 2014 · 4 comments
Closed

Sorting issue #217

paxer opened this issue Aug 25, 2014 · 4 comments
Labels

Comments

@paxer
Copy link

paxer commented Aug 25, 2014

ElasticSearch Version: 1.3.2

I am trying to sort simple collection but no matter what I try it just ignore sorting to me...

{
   "query":{
      "filtered":{
         "query":{
            "match_all":{

            }
         },
         "filter":{
            "bool":{
               "must":[
                  {
                     "terms":{
                        "status":[
                           "active",
                           "featured"
                        ]
                     }
                  }
               ]
            }
         }
      }
   },
   "sort":[
      {
         "price_cents":{
            "order":"asc"
         }
      }
   ]
}

I've noticed in my mapping I have auto_boost = true

{
   "items":{
      "mappings":{
         "item":{
            "dynamic":"false",
            "_all":{
               "auto_boost":true
            },
            "properties":{
               "price_cents":{
                  "type":"integer"
               },
               "status":{
                  "type":"string"
               },
               "title":{
                  "type":"string",
                  "boost":10.0,
                  "analyzer":"snowball"
               }
            }
         }
      }
   }
}

my mapping is:

mappings :dynamic => false do
  indexes :title, :analyzer => 'snowball', :boost => 10.0
  indexes :status     
  indexes :price_cents, :type => :integer, :index => 'not_analyzed'
end

I wonder is the "auto_boost": true the reason of sort ignore? I can't find the correct way how to turn it to false and check...

@karmi
Copy link
Contributor

karmi commented Aug 25, 2014

The auto_boost option shouldn't be related to sorting the data here. If you come with a complete code, eg. index created, data indexed, query executed, I can have a look at it, otherwise no ide.

@karmi karmi added the question label Aug 25, 2014
@paxer
Copy link
Author

paxer commented Aug 25, 2014

sorry, not sure how and what the code related to "index created" , "data indexed" "query executed"? I use rake task provided by this gem to generate the index

rake environment elasticsearch:import:model CLASS='Item' FORCE=y

query is exactly like in the example above..

and the data looks like like:

{
  "_index" : "items",
  "_type" : "item",
  "_id" : "185",
  "_version" : 1,
  "found" : true,
  "_source":{"title":"Test","price_cents":1200,"status":"active"}
}

@paxer
Copy link
Author

paxer commented Aug 25, 2014

I found the issue, it is kind of related to the current bug with .records (#206), because of it does not paginating correctly I used temporary this construction

    @paginates_items = Item.search(params).page(params[:page]).per(60).results
    item_ids = @paginates_items.collect(&:id)
    @items = Item.where(:id => item_ids)

but I forgot that where(:id => items_id) completely break the order...

@paxer paxer closed this as completed Aug 25, 2014
@karmi
Copy link
Contributor

karmi commented Aug 26, 2014

There is no verified bug in #206.

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