在localhost和我的Heroku登台应用程序上,pg_search工作得很好。
在我的Heroku产品应用程序中,除了参考模型(我仍然想要包括)之外,pg_search仍然显示我的脚注模型(我不想再包括)的搜索结果。
我有......
# /app/models/reference.rb
class Reference < ActiveRecord::Base
has_paper_trail
include PgSearch
multisearchable :against => [:source_text, :citation]
end
我已从include PgSearch
删除/app/models/footnote.rb
。
我的流程从手动将一些工作人员分配到应用程序开始。 (我通常会自动使用无用工作。)
然后我这样做:
$ heroku run rails console --app testivate
Running `rails console` attached to terminal... up, run.2840
Connecting to database specified by DATABASE_URL
Loading production environment (Rails 3.2.11)
irb(main):001:0> PgSearch::Footnote.delete_all
NameError: uninitialized constant PgSearch::Footnote
irb(main):002:0> PgSearch::Reference.delete_all
irb(main):003:0> PgSearch::Multisearch.rebuild(Reference)
(1.3ms) BEGIN
SQL (56.2ms) DELETE FROM "pg_search_documents" WHERE "pg_search_documents"."searchable_type" = 'Reference'
(1279.8ms) INSERT INTO "pg_search_documents" (searchable_type, searchable_id, content, created_at, updated_at)
SELECT 'Reference' AS searchable_type,
"references".id AS searchable_id,
(
coalesce("references".source_text::text, '') || ' ' || coalesce("references".citation::text, '')
) AS content,
'2013-04-02 01:05:09.330250' AS created_at,
'2013-04-02 01:05:09.330250' AS updated_at
FROM "references"
(33.8ms) COMMIT
=> #<PG::Result:0x00000006c849b0>
irb(main):004:0>
最后一步立即返回其结果#<PG::Result:0x00000006c849b0>
,尽管我刚刚要求pg_search索引53个文件,每个文件有3000到15,000个单词。
我可以假设重建过程正在进行中吗?有没有办法确认何时完成,这样我可以缩减工人流程? (我还需要为此分配工作流程吗?)
顺便说一下,以下方法也需要几秒钟,这似乎不对:$ heroku run rake pg_search:multisearch:rebuild[Reference] --app testivate
Running `rake pg_search:multisearch:rebuild[Reference]` attached to terminal... up, run.3303
Connecting to database specified by DATABASE_URL
(1.5ms) BEGIN
SQL (95.4ms) DELETE FROM "pg_search_documents" WHERE "pg_search_documents"."searchable_type" = 'Reference'
(1070.3ms) INSERT INTO "pg_search_documents" (searchable_type, searchable_id, content, created_at, updated_at)
SELECT 'Reference' AS searchable_type,
"references".id AS searchable_id,
(
coalesce("references".source_text::text, '') || ' ' || coalesce("references".citation::text, '')
) AS content,
'2013-04-02 01:10:07.355707' AS created_at,
'2013-04-02 01:10:07.355707' AS updated_at
FROM "references"
(103.3ms) COMMIT
在所有这些尝试之后,我仍然在搜索结果中获得了Footnote模型的实例。我该怎样摆脱它们?
答案 0 :(得分:0)
有点苛刻,但heroku run rake db:migrate:redo
做了伎俩。