{"action":"created","issue":{"url":"https://api.github.com/repos/ankane/searchkick/issues/1035","repository_url":"https://api.github.com/repos/ankane/searchkick","labels_url":"https://api.github.com/repos/ankane/searchkick/issues/1035/labels{/name}","comments_url":"https://api.github.com/repos/ankane/searchkick/issues/1035/comments","events_url":"https://api.github.com/repos/ankane/searchkick/issues/1035/events","html_url":"https://github.com/ankane/searchkick/issues/1035","id":279270011,"number":1035,"title":"Searchkick returns no records after reindexing from model","user":{"login":"abhinaykumar","id":4496810,"avatar_url":"https://avatars1.githubusercontent.com/u/4496810?v=4","gravatar_id":"","url":"https://api.github.com/users/abhinaykumar","html_url":"https://github.com/abhinaykumar","followers_url":"https://api.github.com/users/abhinaykumar/followers","following_url":"https://api.github.com/users/abhinaykumar/following{/other_user}","gists_url":"https://api.github.com/users/abhinaykumar/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinaykumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinaykumar/subscriptions","organizations_url":"https://api.github.com/users/abhinaykumar/orgs","repos_url":"https://api.github.com/users/abhinaykumar/repos","events_url":"https://api.github.com/users/abhinaykumar/events{/privacy}","received_events_url":"https://api.github.com/users/abhinaykumar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-05T07:13:03Z","updated_at":"2018-02-15T04:29:16Z","closed_at":"2018-02-15T04:29:16Z","author_association":"NONE","body":"@ankane sorry for disturbing you like this but I am unable to figure out why searchkick returns no records right after when I run this method from `Course` model:\r\n\r\n```ruby\r\ndef self.reindex_course\r\n     index = Course.reindex(async: true, refresh_interval: \"5s\")\r\n     Course.search_index.promote(index[:index_name], update_refresh_interval: true)\r\n     Course.search_index.clean_indices\r\nend\r\n```\r\nThis is the method I am calling from an associated model `Instructor`.\r\nwhich looks like this:\r\n```ruby\r\nclass Instructor < ActiveRecord::Base\r\nbelongs_to :teacher, :class_name => \"User\", :foreign_key => \"user_id\"\r\nbelongs_to :instructorable, polymorphic: true\r\nafter_commit :reindex_course\r\n\r\nprivate\r\n  def reindex_course\r\n     Course.reindex_course\r\n  end\r\nend\r\n```\r\nthis is the response I get after reindexing from model.\r\n```\r\nETHON: performed EASY effective_url=http://xx:xxxx@xy.xyz.xx.xyz/elasticsearch/courses_development/_search response_code=200 return_code=ok total_time=0.733799\r\n  Search (738.0ms)  curl http://xx.xxx.xx.xxx:80/courses_development/_search?pretty -d '{\"query\":{\"bool\":{\"must\":{\"dis_max\":{\"queries\":[{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":100.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"name.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}},{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"instructor_name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"instructor_name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":100.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"instructor_name.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}},{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"description.word_start\":{\"query\":\"Elasticsearch\",\"boost\":500.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"description.word_start\":{\"query\":\"Elasticsearch\",\"boost\":50.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"description.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":500.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}}]}},\"filter\":[{\"term\":{\"institute_id\":113}},{\"term\":{\"searchable\":true}}]}},\"size\":1000,\"from\":0,\"timeout\":\"11s\",\"_source\":false}'\r\n=> #<Searchkick::Results:0x007fcb8c9cb378\r\n @klass=nil,\r\n @options=\r\n  {:page=>1,\r\n   :per_page=>1000,\r\n   :padding=>0,\r\n   :load=>true,\r\n   :includes=>nil,\r\n   :model_includes=>nil,\r\n   :json=>false,\r\n   :match_suffix=>:word_start,\r\n   :highlighted_fields=>[],\r\n   :misspellings=>true},\r\n @response=\r\n  {\"took\"=>1,\r\n   \"timed_out\"=>false,\r\n   \"_shards\"=>{\"total\"=>5, \"successful\"=>5, \"skipped\"=>0, \"failed\"=>0},\r\n   \"hits\"=>{\"total\"=>0, \"max_score\"=>nil, \"hits\"=>[]}}>\r\n```\r\n\r\nwhere as when I run `Course.reindex` or `bundle exec rake searchkick:reindex CLASS=Course`\r\nits correctly returns the result:\r\n```\r\n[33] pry(main)> Searchkick.search \"Elasticsearch\", operator: \"or\",index_name: [Course],where:{institute_id: 113, searchable: true},fields: ['name^100','instructor_name^100','description^50'],match: :word_start,misspellings: {edit_distance: 2}\r\nETHON: performed EASY effective_url=http://xx:xx@xxx.xx.xx.xxx/elasticsearch/courses_development/_search response_code=200 return_code=ok total_time=0.57072\r\n  Search (573.5ms)  curl http://xxx.xx.xx.xxx:80/courses_development/_search?pretty -d '{\"query\":{\"bool\":{\"must\":{\"dis_max\":{\"queries\":[{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":100.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"name.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}},{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"instructor_name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"instructor_name.word_start\":{\"query\":\"Elasticsearch\",\"boost\":100.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"instructor_name.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":1000.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}},{\"bool\":{\"must\":{\"bool\":{\"should\":[{\"match\":{\"description.word_start\":{\"query\":\"Elasticsearch\",\"boost\":500.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}},{\"match\":{\"description.word_start\":{\"query\":\"Elasticsearch\",\"boost\":50.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\",\"fuzziness\":2,\"prefix_length\":0,\"max_expansions\":3,\"fuzzy_transpositions\":true}}}]}},\"should\":{\"match\":{\"description.analyzed\":{\"query\":\"Elasticsearch\",\"boost\":500.0,\"operator\":\"or\",\"analyzer\":\"searchkick_word_search\"}}}}}]}},\"filter\":[{\"term\":{\"institute_id\":113}}]}},\"size\":1000,\"from\":0,\"timeout\":\"11s\",\"_source\":false}'\r\n=> #<Searchkick::Results:0x007fcb8f2893a0\r\n @klass=nil,\r\n @options=\r\n  {:page=>1,\r\n   :per_page=>1000,\r\n   :padding=>0,\r\n   :load=>true,\r\n   :includes=>nil,\r\n   :model_includes=>nil,\r\n   :json=>false,\r\n   :match_suffix=>:word_start,\r\n   :highlighted_fields=>[],\r\n   :misspellings=>true},\r\n @response=\r\n  {\"took\"=>32,\r\n   \"timed_out\"=>false,\r\n   \"_shards\"=>{\"total\"=>5, \"successful\"=>5, \"skipped\"=>0, \"failed\"=>0},\r\n   \"hits\"=>\r\n    {\"total\"=>2,\r\n     \"max_score\"=>19030.512,\r\n     \"hits\"=>\r\n      [{\"_index\"=>\"courses_development_20171204170257200\",\r\n        \"_type\"=>\"course\",\r\n        \"_id\"=>\"4792\",\r\n        \"_score\"=>19030.512},\r\n       {\"_index\"=>\"courses_development_20171204170257200\",\r\n        \"_type\"=>\"course\",\r\n        \"_id\"=>\"4782\",\r\n        \"_score\"=>14400.825}]}}>\r\n```\r\nCan you please point out whats going wrong here?"},"comment":{"url":"https://api.github.com/repos/ankane/searchkick/issues/comments/365822556","html_url":"https://github.com/ankane/searchkick/issues/1035#issuecomment-365822556","issue_url":"https://api.github.com/repos/ankane/searchkick/issues/1035","id":365822556,"user":{"login":"ankane","id":220358,"avatar_url":"https://avatars3.githubusercontent.com/u/220358?v=4","gravatar_id":"","url":"https://api.github.com/users/ankane","html_url":"https://github.com/ankane","followers_url":"https://api.github.com/users/ankane/followers","following_url":"https://api.github.com/users/ankane/following{/other_user}","gists_url":"https://api.github.com/users/ankane/gists{/gist_id}","starred_url":"https://api.github.com/users/ankane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankane/subscriptions","organizations_url":"https://api.github.com/users/ankane/orgs","repos_url":"https://api.github.com/users/ankane/repos","events_url":"https://api.github.com/users/ankane/events{/privacy}","received_events_url":"https://api.github.com/users/ankane/received_events","type":"User","site_admin":false},"created_at":"2018-02-15T04:29:16Z","updated_at":"2018-02-15T04:29:16Z","author_association":"OWNER","body":"Hey @abhinaykumar, to clean up the issue tracker, I'm closing out all questions. Please ask on Stack Overflow if you're still having issues."}}
{"actor":{"display_login":"ankane"}}