Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Settings take locally, but not on Heroku with Bonsai - again #386

Closed
iterion opened this issue Jun 19, 2012 · 11 comments
Closed

Settings take locally, but not on Heroku with Bonsai - again #386

iterion opened this issue Jun 19, 2012 · 11 comments

Comments

@iterion
Copy link

iterion commented Jun 19, 2012

Model/Mapping I'm having trouble with:

  include Tire::Model::Search
  include Tire::Model::Callbacks
  index_name BONSAI_INDEX_NAME

  #elasticsearch mapping -------
  settings :analysis => {
            :filter => {
              :name_ngram  => {
                "type"     => "nGram",
                "max_gram" => 8,
                "min_gram" => 2 }
              },
              :analyzer => {
                :name_analyzer => {
                  "tokenizer"    => "standard",
                  "filter"       => ["lowercase", "stop", "name_ngram"],
                  "type"         => "custom"
                }
              }
            } do
      mapping do
        indexes :id, type: 'integer'
        indexes :name, analyzer: 'name_analyzer'
        indexes :other_names, analyzer: 'name_analyzer'
        indexes :city
        indexes :state
        indexes :domain
      end
  end

  # def to_indexed_json
  #   to_json(methods: [:name])
  # end

  class << self
    def search(params)
      tire.search(page: params[:page], per_page: per_page, load: true) do
        query do
          boolean do
            if params[:query].present?
              must { term :other_names, params[:query] }
            end
          end
        end
      end
    end
  end

Also, I have set up an initializer at config/initializers/bonsai.rb as recommended and ran the below steps, all to no avail:

      1)  drop out `to_indexed_json` from your University model ( at the opposit of README indication )
      2)  remove & add back Bonsai.io/Heroku add-on ( this will remove your index on Heroku, be careful ! )
      3)  reindex ElasticSearch by running `heroku run:detached rake environment tire:import CLASS='University'`
           ( Heroku will bill this extra "run" process so know what you're doing )

I'm running:
rails (3.2.5)
tire (0.4.2)

Let me know if more detail is needed.

@iterion
Copy link
Author

iterion commented Jun 19, 2012

Exploring the console on heroku - I found this:

irb(main):009:0> index.settings
NoMethodError: undefined method `[]' for nil:NilClass
    from /app/vendor/bundle/ruby/1.9.1/gems/tire-0.4.2/lib/tire/index.rb:62:in `settings'
    from (irb):9
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.5/lib/rails/commands/console.rb:47:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.5/lib/rails/commands/console.rb:8:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.5/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
irb(main):010:0> index.response
=> 200 : {"[bonsai_index_name]-[large_integer]":{"settings":{"index.number_of_replicas":"1","index.number_of_shards":"1"}}}

The error obviously comes from setting the index name based on the ENV variable as the index name in the response does not match. Might this be preventing us from saving the mapping too?

Also, this:

irb(main):021:0> index.create
=> false
irb(main):022:0> index.response
=> 401 : {"error": "Not authorized: Some endpoints are admin-only, ask support@onemorecloud.com."}

--edit-- More Info:

If I modify the name of the index like so:

index.instance_variable_set :@name, "#{index.name}-[large_int_that_was_returned]/university"

I can then run:

index.delete
 => true

@zacksiri
Copy link

This could be related to my issue although mine is having issues with callbacks not get request, I can run tire import but it seems if I update create or delete it doesn't work.

@zacksiri
Copy link

Btw interesting that I am also on 3.2.5 and tire 0.4.2 perhaps there is something not right with this combo?

@iterion
Copy link
Author

iterion commented Jun 25, 2012

@zacksiri take a look at https://saas.found.no/

Their support actually gets back to me, unlike bonsai.

@zacksiri
Copy link

hey, yea i am thinking of switching too been having too many issues with bonsai

@karmi
Copy link
Owner

karmi commented Jun 26, 2012

@iterion Sorry for not getting back to you here... these problems with Bonsai are piling up... will have to find some time to investigate it.

@iterion
Copy link
Author

iterion commented Jun 26, 2012

@karmi no worries, things are working quite well for me with Found

Most of the issues I saw with Bonsai came from restrictions on their end.

@karmi
Copy link
Owner

karmi commented Jul 26, 2012

@iterion Should we close this, then? I'm afraid I still can't see anything wrong in the setup...

@iterion
Copy link
Author

iterion commented Aug 6, 2012

@karmi Yeah, migrating to a different provider fixed the issue, so it appears tire is fine.

@iterion iterion closed this as completed Aug 6, 2012
@karmi
Copy link
Owner

karmi commented Aug 7, 2012

@iterion Cool.

@nz
Copy link
Contributor

nz commented Feb 20, 2013

For posterity: this issue was addressed in Bonsai a couple months ago, back in October 2012. We've also since launched to production in January 2013 and generally work pretty smoothly with Tire's conventions these days.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants