在 localhost 和我的 Heroku staging 应用程序上,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
.
我的流程从手动将一些工作人员分配给应用程序开始。(我通常使用 workless 自动执行此操作。)
然后我做:
$ 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
在所有这些尝试之后,我仍然在搜索结果中获得了脚注模型的实例。我怎样才能摆脱它们?