2013-03-01 35 views
0

我在應用程序中添加了即時搜索功能。AJAX搜索在開發/生產中的功能有所不同

它的工作原理正是我希望它在本地服務器上:

  • 海峽名單上的按鍵
  • 案無關
  • 允許復位(所以如果我輸入一些東西,然後刪除它,搜索被重置,而不是縮小)。它也允許回溯,所以如果我輸錯並刪除錯字的字母,搜索將相應地修復。

在生產中,行爲完全是奇怪的。雖然它也按鍵搜索,但它有一些奇怪的問題。

  • 它是區分大小寫的(與開發不同) - 這不是我想要的。
  • 它在復位方面的表現很奇怪。如果我輸入類似「instatn」的內容,然後更正錯誤,則不會重新搜索。如果我刪除整個條目,它也不會重新搜索。然而,奇怪的是,
  • 如果我刪除搜索詞並輸入單個字母,它會重置搜索。
  • 它似乎沒有正確搜索,期限。如果我輸入「z」,儘管我沒有找到包含「z」的項目,但它們都沒有消失。另一方面,如果我輸入,比如說「Blogging」,那麼這個列表實際上會縮小到名稱中帶有這個詞的兩個項目。

任何想法這裏發生了什麼?爲什麼這兩個不同?我該如何解決它?讓我知道什麼樣的代碼可能有助於解釋。

我的代碼:

archive.html.erb

<%= form_tag @post, :method => 'get', :id => "posts_search", class: "search_form squeeze form-inline" do %> 
    <p> 
    <%= text_field_tag :search, params[:search], 
    placeholder: "Search titles:", id: "search_field" %> 
    <%= submit_tag "Search", name: nil, class: "btn squeeze search" %> 
    </p> 
    <div id="list"><%= render 'search' %></div> 
<% end %> 

_search.html.erb

<ul class="blog_links"> 
<% @posts.first(@link_num).each do |p| %> 
    <li class="total_hover"> 
     <%= p.name %> 
    </li> 
<% end %> 
</ul> 

archive.js.erb

$("#list").html("<%= escape_javascript(render("search")) %>"); 

posts_controller.rb

def archive 
    @posts = Post.search(params[:search]).reverse 

    respond_to do |format| 
     format.html # index.html.erb 
     format.json { render json: @posts } 
     format.js 
    end 
    end 

def search 
    @posts = Post.search(params[:search]).reverse 
    render json: { results: @posts } 
end 

post.rb

def self.search(search) 
    if search 
     where('name LIKE ?', "%#{search}%") 
    else 
     scoped 
    end 
    end 

Javascript角/ posts.js.coffee

@search = -> 
    $.get $('#posts_search').attr("action"), $("#posts_search").serialize(), null, "script" 

$ -> 
    $('#posts_search input').keypress -> search() 

    $('#posts_search').submit (e) -> 
    e.preventDefault() 
    search() 

路線。RB

match '/search', to: 'posts#search' 
match '/archive', to: 'posts#archive' 

編輯提供一些線索,我在執行這兩個環境中相同的用戶行爲和發佈的博客。我要做的是:

  1. 加載包含搜索的頁面。
  2. 輸入 「Blgo」
  3. 刪除 「走出去」 與 「OG」
  4. 刪除一切,然後搜索 「的Insta」

開發日誌

Started GET "/archive" for 127.0.0.1 at 2013-02-28 23:20:52 -0800 
Processing by PostsController#archive as HTML 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (55.7ms) 
    Rendered posts/archive.html.erb within layouts/application (57.0ms) 
    Rendered layouts/_shim.html.erb (0.0ms) 
    Rendered layouts/_header.html.erb (0.7ms) 
Completed 200 OK in 74ms (Views: 72.2ms | ActiveRecord: 0.3ms) 

# Cut out bootstrap loading etc for brevity 

Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453454" for 127.0.0.1 at 2013-02-28 23:20:54 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453454"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (13.2ms) 
    Rendered posts/archive.js.erb (14.7ms) 
Completed 200 OK in 18ms (Views: 16.6ms | ActiveRecord: 0.3ms) 


Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453455" for 127.0.0.1 at 2013-02-28 23:20:54 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453455"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.4ms) 
    Rendered posts/archive.js.erb (3.7ms) 
Completed 200 OK in 7ms (Views: 5.6ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453456" for 127.0.0.1 at 2013-02-28 23:20:54 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453456"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.2ms) 
    Rendered posts/archive.js.erb (3.4ms) 
Completed 200 OK in 7ms (Views: 5.7ms | ActiveRecord: 0.3ms) 


Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453457" for 127.0.0.1 at 2013-02-28 23:20:54 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453457"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.0ms) 
    Rendered posts/archive.js.erb (3.2ms) 
Completed 200 OK in 6ms (Views: 5.1ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453458" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453458"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (1.9ms) 
    Rendered posts/archive.js.erb (3.1ms) 
Completed 200 OK in 6ms (Views: 4.9ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453459" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453459"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%') 
    Rendered posts/_search.html.erb (0.0ms) 
    Rendered posts/archive.js.erb (1.3ms) 
Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.1ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453460" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453460"} 
    [1m[36mPost Load (0.1ms)[0m [1mSELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%')[0m 
    Rendered posts/_search.html.erb (0.0ms) 
    Rendered posts/archive.js.erb (1.2ms) 
Completed 200 OK in 4ms (Views: 3.3ms | ActiveRecord: 0.1ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blgo&_=1362122453461" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blgo", "_"=>"1362122453461"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blgo%') 
    Rendered posts/_search.html.erb (0.0ms) 
    Rendered posts/archive.js.erb (1.3ms) 
Completed 200 OK in 5ms (Views: 3.9ms | ActiveRecord: 0.1ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122453462" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122453462"} 
    [1m[36mPost Load (0.1ms)[0m [1mSELECT "posts".* FROM "posts" WHERE (name LIKE '%blg%')[0m 
    Rendered posts/_search.html.erb (0.0ms) 
    Rendered posts/archive.js.erb (1.2ms) 
Completed 200 OK in 4ms (Views: 3.2ms | ActiveRecord: 0.1ms) 


Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453463" for 127.0.0.1 at 2013-02-28 23:20:55 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453463"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.0ms) 
    Rendered posts/archive.js.erb (3.2ms) 
Completed 200 OK in 6ms (Views: 5.1ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453464" for 127.0.0.1 at 2013-02-28 23:20:56 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453464"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.1ms) 
    Rendered posts/archive.js.erb (3.4ms) 
Completed 200 OK in 7ms (Views: 5.3ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122453465" for 127.0.0.1 at 2013-02-28 23:20:56 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122453465"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blo%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.8ms) 
    Rendered posts/archive.js.erb (5.0ms) 
Completed 200 OK in 9ms (Views: 7.9ms | ActiveRecord: 0.3ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blog&_=1362122453466" for 127.0.0.1 at 2013-02-28 23:20:56 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blog", "_"=>"1362122453466"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blog%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.8ms) 
    Rendered posts/archive.js.erb (4.1ms) 
Completed 200 OK in 7ms (Views: 6.0ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blog&_=1362122453467" for 127.0.0.1 at 2013-02-28 23:20:56 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blog", "_"=>"1362122453467"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blog%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.0ms) 
    Rendered posts/archive.js.erb (3.2ms) 
Completed 200 OK in 7ms (Views: 5.3ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122453468" for 127.0.0.1 at 2013-02-28 23:20:57 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122453468"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%blo%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.1ms) 
    Rendered posts/archive.js.erb (3.3ms) 
Completed 200 OK in 6ms (Views: 5.2ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122453469" for 127.0.0.1 at 2013-02-28 23:20:57 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122453469"} 
    [1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%bl%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (1.9ms) 
    Rendered posts/archive.js.erb (3.1ms) 
Completed 200 OK in 6ms (Views: 5.0ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122453470" for 127.0.0.1 at 2013-02-28 23:20:57 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122453470"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%b%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.0ms) 
    Rendered posts/archive.js.erb (3.2ms) 
Completed 200 OK in 6ms (Views: 5.0ms | ActiveRecord: 0.2ms) 


Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453471" for 127.0.0.1 at 2013-02-28 23:20:58 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453471"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%%') 
    [1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (17.9ms) 
    Rendered posts/archive.js.erb (19.4ms) 
Completed 200 OK in 23ms (Views: 21.2ms | ActiveRecord: 0.4ms) 


Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122453472" for 127.0.0.1 at 2013-02-28 23:20:58 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122453472"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (12.2ms) 
    Rendered posts/archive.js.erb (13.7ms) 
Completed 200 OK in 17ms (Views: 15.6ms | ActiveRecord: 0.3ms) 


Started GET "/archive?utf8=%E2%9C%93&search=I&_=1362122453473" for 127.0.0.1 at 2013-02-28 23:20:58 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"I", "_"=>"1362122453473"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%I%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (4.6ms) 
    Rendered posts/archive.js.erb (5.8ms) 
Completed 200 OK in 9ms (Views: 7.7ms | ActiveRecord: 0.2ms) 

#... You get the picture. I went over character count. (!) 

Started GET "/archive?utf8=%E2%9C%93&search=Insta&_=1362122453481" for 127.0.0.1 at 2013-02-28 23:20:59 -0800 
Processing by PostsController#archive as JS 
    Parameters: {"utf8"=>"✓", "search"=>"Insta", "_"=>"1362122453481"} 
    [1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts" WHERE (name LIKE '%Insta%') 
    [1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", 1]] 
    Rendered posts/_search.html.erb (2.2ms) 
    Rendered posts/archive.js.erb (3.5ms) 
Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.3ms) 

更換heroku日誌

013-03-01T07:23:21+00:00 app[web.1]: Started GET "/archive" for 69.181.104.85 at 2013-03-01 07:23:21 +0000 
2013-03-01T07:23:21+00:00 heroku[router]: at=info method=GET path=/archive host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=43ms status=200 bytes=3343 
2013-03-01T07:23:21+00:00 app[web.1]: Processing by PostsController#archive as HTML 
2013-03-01T07:23:21+00:00 app[web.1]: Completed 200 OK in 20ms (Views: 5.2ms | ActiveRecord: 13.2ms) 
2013-03-01T07:23:21+00:00 app[web.1]: Rendered posts/_search.html.erb (2.2ms) 
2013-03-01T07:23:21+00:00 app[web.1]: Rendered layouts/_header.html.erb (0.5ms) 
2013-03-01T07:23:21+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms) 
2013-03-01T07:23:21+00:00 app[web.1]: Rendered posts/archive.html.erb within layouts/application (2.8ms) 

2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122601827" for 69.181.104.85 at 2013-03-01 07:23:24 +0000 
2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/_search.html.erb (2.5ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122601827"} 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/archive.js.erb (3.0ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 3.6ms | ActiveRecord: 7.1ms) 

2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=b&_=1362122601828" for 69.181.104.85 at 2013-03-01 07:23:24 +0000 
2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:24+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"b", "_"=>"1362122601828"} 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/archive.js.erb (0.4ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/_search.html.erb (0.0ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 0.9ms | ActiveRecord: 3.7ms) 
2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=b&_=1362122601828 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=53ms status=200 bytes=53 
2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=&_=1362122601827 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=198ms status=200 bytes=703 

2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122601829" for 69.181.104.85 at 2013-03-01 07:23:24 +0000 
2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/_search.html.erb (0.0ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122601829"} 
2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.9ms | ActiveRecord: 2.9ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/archive.js.erb (0.4ms) 
2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=bl&_=1362122601829 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=89ms status=200 bytes=53 
2013-03-01T07:23:24+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=blg&_=1362122601830 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=20ms status=200 bytes=53 
2013-03-01T07:23:24+00:00 app[web.1]: Completed 200 OK in 4ms (Views: 0.8ms | ActiveRecord: 2.6ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"blg", "_"=>"1362122601830"} 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/archive.js.erb (0.4ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Rendered posts/_search.html.erb (0.0ms) 
2013-03-01T07:23:24+00:00 app[web.1]: Processing by PostsController#archive as JS 

2013-03-01T07:23:24+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=blg&_=1362122601830" for 69.181.104.85 at 2013-03-01 07:23:24 +0000 

2013-03-01T07:23:27+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=bl&_=1362122601831" for 69.181.104.85 at 2013-03-01 07:23:27 +0000 
2013-03-01T07:23:28+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=bl&_=1362122601831 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=26ms status=200 bytes=53 
2013-03-01T07:23:28+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"bl", "_"=>"1362122601831"} 
2013-03-01T07:23:28+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:28+00:00 app[web.1]: Rendered posts/_search.html.erb (0.0ms) 
2013-03-01T07:23:28+00:00 app[web.1]: Rendered posts/archive.js.erb (0.3ms) 
2013-03-01T07:23:28+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 0.9ms | ActiveRecord: 2.6ms) 

2013-03-01T07:23:28+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=blo&_=1362122601832" for 69.181.104.85 at 2013-03-01 07:23:28 +0000 
2013-03-01T07:23:28+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:28+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"blo", "_"=>"1362122601832"} 
2013-03-01T07:23:28+00:00 app[web.1]: Completed 200 OK in 4ms (Views: 0.8ms | ActiveRecord: 2.6ms) 
2013-03-01T07:23:28+00:00 app[web.1]: Rendered posts/_search.html.erb (0.0ms) 
2013-03-01T07:23:28+00:00 app[web.1]: Rendered posts/archive.js.erb (0.3ms) 
2013-03-01T07:23:28+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=blo&_=1362122601832 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=61ms status=200 bytes=53 

2013-03-01T07:23:30+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=&_=1362122601833" for 69.181.104.85 at 2013-03-01 07:23:30 +0000 
2013-03-01T07:23:30+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:30+00:00 app[web.1]: Rendered posts/archive.js.erb (2.5ms) 
2013-03-01T07:23:30+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"", "_"=>"1362122601833"} 
2013-03-01T07:23:30+00:00 app[web.1]: Completed 200 OK in 7ms (Views: 3.0ms | ActiveRecord: 3.3ms) 
2013-03-01T07:23:30+00:00 app[web.1]: Rendered posts/_search.html.erb (2.1ms) 
2013-03-01T07:23:30+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=&_=1362122601833 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=1ms service=19ms status=200 bytes=703 

2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=I&_=1362122601834" for 69.181.104.85 at 2013-03-01 07:23:32 +0000 
2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=I&_=1362122601834 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=20ms status=200 bytes=218 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/archive.js.erb (1.0ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 2.2ms | ActiveRecord: 2.6ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"I", "_"=>"1362122601834"} 
2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/_search.html.erb (0.7ms) 

2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=In&_=1362122601835" for 69.181.104.85 at 2013-03-01 07:23:32 +0000 
2013-03-01T07:23:32+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"In", "_"=>"1362122601835"} 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/_search.html.erb (0.7ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/archive.js.erb (1.1ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.5ms | ActiveRecord: 2.8ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=In&_=1362122601835 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=27ms status=200 bytes=218 

2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Ins&_=1362122601836" for 69.181.104.85 at 2013-03-01 07:23:32 +0000 
2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.4ms | ActiveRecord: 2.8ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"Ins", "_"=>"1362122601836"} 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/_search.html.erb (0.7ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/archive.js.erb (1.0ms) 

2013-03-01T07:23:32+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Inst&_=1362122601837" for 69.181.104.85 at 2013-03-01 07:23:32 +0000 
2013-03-01T07:23:32+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:32+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"Inst", "_"=>"1362122601837"} 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/_search.html.erb (0.8ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 1.6ms | ActiveRecord: 3.4ms) 
2013-03-01T07:23:32+00:00 app[web.1]: Rendered posts/archive.js.erb (1.1ms) 
2013-03-01T07:23:32+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=Inst&_=1362122601837 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=18ms status=200 bytes=218 

2013-03-01T07:23:33+00:00 app[web.1]: Started GET "/archive?utf8=%E2%9C%93&search=Insta&_=1362122601838" for 69.181.104.85 at 2013-03-01 07:23:33 +0000 
2013-03-01T07:23:33+00:00 app[web.1]: Processing by PostsController#archive as JS 
2013-03-01T07:23:33+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "search"=>"Insta", "_"=>"1362122601838"} 
2013-03-01T07:23:33+00:00 app[web.1]: Completed 200 OK in 5ms (Views: 1.4ms | ActiveRecord: 2.9ms) 
2013-03-01T07:23:33+00:00 app[web.1]: Rendered posts/archive.js.erb (1.0ms) 
2013-03-01T07:23:33+00:00 app[web.1]: Rendered posts/_search.html.erb (0.7ms) 
2013-03-01T07:23:33+00:00 heroku[router]: at=info method=GET path=/archive?utf8=%E2%9C%93&search=Insta&_=1362122601838 host=<my_site>.com fwd="69.181.104.85" dyno=web.1 queue=0 wait=0ms connect=2ms service=15ms status=200 bytes=218 

同樣,雖然開發搜索工作完美,並且我認爲一般情況下預期的是,在生產中,上述情況發生了什麼:列表縮小,直到我在「blg」中鍵入g,此時沒有更多的列表項目。當我刪除「go」並輸入「og」時,該列表不會重新展開,以將標題中的「blog」項目合併在一起。當我刪除搜索框中的所有字母時,它也沒有包含所有內容。

只有當我輸入「I」時,搜索纔會重置,而且由於Instant實際上是列表中的一個術語,因此縮小到名稱中包含「Insta」的一個項目。

所以,很奇怪。任何想法這裏有什麼?

回答

0

這(分離)最終只是一個數據庫問題。

我正在運行sqlite開發和postgresql生產,並且這兩個響應方式與我的搜索方法不同。當我將開發轉換爲pg時,搜索在兩種環境中都同樣受到破壞,我決定使用Thinking Sphinx而不是自制解決方案。

相關問題