brewster / elastictastic

Object-document mapper and lightweight API adapter for ElasticSearch
MIT License
88 stars 13 forks source link

"ignore_unmapped" doesn't work somehow #20

Closed kostia closed 11 years ago

kostia commented 12 years ago

Hello,

I got following model:

class Keyword
  include Elastictastic::Document

  field :slug
  field :category

  def self.sort_by_category_and_slug
     sort [
       {category: {order: :asc, ignore_unmapped: true}},
       {slug: {order: :asc, ignore_unmapped: true}},
     ]
  end
end

Now I'm doing following several times while having no slugs at all:

100.times { |i| puts i; Keyword.sort_by_category_and_slug.to_a }

And I'm getting different results every time:

0
1
2
3
4
5
Elastictastic::ServerError::IOException: [Can't sort on string types with more than one value per doc, or more than one token per field]; 
from /Users/kostiaka/develop/private/elastictastic/lib/elastictastic/middleware.rb:75:in `raise_error'

0
1
2
Elastictastic::ServerError::IOException: [Can't sort on string types with more than one value per doc, or more than one token per field]; 
from /Users/kostiaka/develop/private/elastictastic/lib/elastictastic/middleware.rb:75:in `raise_error'

0
Elastictastic::ServerError::IOException: [Can't sort on string types with more than one value per doc, or more than one token per field]; 
from /Users/kostiaka/develop/private/elastictastic/lib/elastictastic/middleware.rb:75:in `raise_error'

0
1
2
3
Elastictastic::ServerError::IOException: [Can't sort on string types with more than one value per doc, or more than one token per field]; 
from /Users/kostiaka/develop/private/elastictastic/lib/elastictastic/middleware.rb:75:in `raise_error'

Why for God's sake?!!!

When I'm doing the same test with curl in console I'm getting no errors at all...

kostia commented 12 years ago

When I'm calling following 100 times I'm getting not a single error:

curl -XPOST 'localhost:9200/stellen24_development/keywords/_search?pretty=true' -d '
{
    "sort" : [
        {
            "slug" : {
                "order" : "asc" ,
                "ignore_unmapped" : true
            }
        },
        {
            "category" : {
                "order" : "asc" ,
                "ignore_unmapped" : true
            }
        }
    ]
}
'
outoftime commented 12 years ago

What's the output when you call 'params' on the scope created by your method?

On Tue, Oct 23, 2012 at 6:21 PM, Kostiantyn Kahanskyi < notifications@github.com> wrote:

When I'm calling following 100 times I'm getting not a single error:

curl -XPOST 'localhost:9200/stellen24_development/keywords/_search?pretty=true' -d '{ "sort" : [ { "slug" : { "order" : "asc" , "ignore_unmapped" : true } }, { "category" : { "order" : "asc" , "ignore_unmapped" : true } } ]}'

— Reply to this email directly or view it on GitHubhttps://github.com/brewster/elastictastic/issues/20#issuecomment-9720646.

kostia commented 12 years ago
[72] pry(main)> Keyword.sort_by_category_and_slug.params
=> {"sort"=>
  [{:category=>{:order=>:asc, :ignore_unmapped=>true}},
   {:slug=>{:order=>:asc, :ignore_unmapped=>true}}]}

Seems to be ok...

kostia commented 12 years ago

Strange... When I'm restarting the ES the error disappears.

It appears again every time I'm doing a destroy_all, followed by sync_mapping, followed by a bulk create (about 2.000 Keywords). Then the error is thrown continuously.

If after that I do a destroy_all followed by a sync_mapping again, than the error appears for several time, but not every time.

If I then restart the ES the error disappears.

kostia commented 11 years ago

As I'm the only one ever experienced this issue and I'm not experiencing it anymore, I'm closing the issue.