Search code examples
ruby-on-railselasticsearchsearchkick

When installing elasticsearch and running the Searchkick's reindex command, do I need to be inside the master branch?


Should I be inside the master branch when installing Elasticsearch and running the rake searchkick:reindex command?

Because all the tutorials I found are inside the master branch, but when I'm adding a feature to my app, I always checkout on other branch and just merge it if the feature works.


Solution

  • The elasticsearch will be installed in your system so it will have no relation with your git branch. The things which will have relation with your git branch is the configuration of your elasticsearch server which can be defined different in different branches. And the other things which will matter while running rake searchkick:reindex is your search_data method.

    Suppose in your master branch your search_data method is like this:

    def search_data
      {
        name: name,
        department_name: department.name
      }
    end
    

    And now you checkout to new branch and make changes in this method:

    def search_data
      {
        name: name,
        department_name: department.name,
        on_sale: sale_price.present?
      }
    end
    

    So you will have to run a reindex so the new data has been indexed in the elasticsearch. And this(reindexed data) is also not dependent on the branch but what should be reindexed is dependent on the branch.

    Hope this helps.