【问题标题】:Migrating a rails2 app to rails 3, difficulty in getting thinking sphinx indexing to run将 rails2 应用程序迁移到 rails 3,难以思考 sphinx 索引运行
【发布时间】:2014-08-13 16:05:52
【问题描述】:

rails 2.3.10 正在迁移到 rails 3.2.18。它完全围绕全文索引。 rails 2 版本在 postgresql 9.0.4 上运行,而迁移版本在 9.3.5 上运行

数据表被移植到新的 rails 3 版本而没有错误。我确实有几个模型需要一些改进,但不是与这个问题/案例相关的对象。

rake ts:configure 

生成 sphinx.conf 文件。它看起来与原生 rails3 sphinx/thinking-sphinx 应用略有不同。

source filodiretto_core_0
{
  type = pgsql
  sql_host = localhost
  sql_user = jerdvo
  sql_pass = 
  sql_db = fna_development
  sql_query_pre = SET TIME ZONE UTC
  sql_query = SELECT "filodirettos"."id" * 24 + 0 AS "id", "filodirettos"."titolo" AS "titolo", "filodirettos"."domanda" AS "domanda", "filodirettos"."data" AS "data", "filodirettos"."risposta" AS "risposta", "filodirettos"."id" AS "sphinx_internal_id", 'Filodiretto' AS "sphinx_internal_class", 0 AS "sphinx_deleted" FROM "filodirettos"  WHERE ("filodirettos"."id" BETWEEN $start AND $end) GROUP BY "filodirettos"."id", "filodirettos"."titolo", "filodirettos"."domanda", "filodirettos"."data", "filodirettos"."risposta", "filodirettos"."id"
  sql_query_range = SELECT COALESCE(MIN("filodirettos"."id"), 1), COALESCE(MAX("filodirettos"."id"), 1) FROM "filodirettos" 
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = sphinx_deleted
  sql_attr_string = sphinx_internal_class
  sql_query_info = SELECT "filodirettos".* FROM "filodirettos"  WHERE ("filodirettos"."id" = ($id - 0) / 24)
}

index filodiretto_core
{
  type = plain
  path = /Users/jerdvo/r/fna/shared/sphinx/filodiretto_core
  docinfo = extern
  charset_type = utf-8
  min_infix_len = 2
  enable_star = 1
  source = filodiretto_core_0
}

但是当我启动时

rake ts:index

所有索引都失败了

indexing index 'filodiretto_core'...
ERROR: source 'filodiretto_core_0': unknown type 'pgsql'; skipping.
ERROR: index 'filodiretto_core': failed to configure some of the sources, will not index.
[...] skipping non-plain index 'filodiretto'...

相对的“_index.rb”文件状态

ThinkingSphinx::Index.define :filodiretto, :with => :active_record do
    indexes titolo
    indexes domanda
    indexes data
    indexes risposta
end

我遇到了一个带有本机 rails3 应用程序的 pg_dump 文件。唯一的区别是在文件的顶部,来自 rails 2(和 postgres 9.0.4)的版本状态(在开头)

--
-- Name: crc32(text); Type: FUNCTION; Schema: public; Owner: jerdvo
--

CREATE FUNCTION crc32(word text) RETURNS bigint
    LANGUAGE plpgsql IMMUTABLE
    AS $$
          DECLARE tmp bigint;
          DECLARE i int;
          DECLARE j int;
          DECLARE byte_length int;
          DECLARE word_array bytea;

我不知道这个 'pgsql' 错误是从哪里来的。

【问题讨论】:

    标签: ruby-on-rails-3.2 sphinx thinking-sphinx ruby-on-rails-2 postgresql-9.3


    【解决方案1】:

    您的 Sphinx 副本似乎没有安装 PostgreSQL 支持。您应该使用适当的标志重新安装它 - 如果是 compiling manually,则为 --with-pgsql,或者在通过 Homebrew 安装时使用 --pgsql。还需要 MySQL 支持,但可能已经自动应用了?

    【讨论】:

    • 就是这样!尽管在 indic()es ERROR: index 'norm_core': sql_range_query: ERROR: integer out of range (DSN=pgsql://jerdvo:***@localhost:5432/fna_development). 上遇到了障碍,这是否意味着 Integer 类型的某些列具有另一个值(十进制,alpha ...)?
    • 遍历 8500 条记录,唯一定义为整数的列有适当的数据;但是有些具有 NULL 值,表示为 \N... 只有 total 1019 docs 被索引;从视觉扫描 8 条记录中的 7 条没有空值...
    • 也许用该模型的 TS 索引定义创建另一个票证?但也:我看到超大日期的问题(通常是由于拼写错误,例如输入的年份为 20014 等)。如果您的索引定义中有日期/时间属性,则值得查看那里的最大值。
    • 是的。将相应的问题移至stackoverflow.com/questions/25304951/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多