狮身人面像范围什么也不返回

发布于 2024-12-12 17:50:43 字数 872 浏览 3 评论 0原文

我正在尝试创建一个 sphinx 将索引的简单范围(Ruby on Rails)。正常作用域返回应有的结果,sphinx 作用域不返回结果。

define_index do
  # fields
  indexes :name
  indexes author
  indexes description
  indexes list_of_tags
  indexes approved

  # attributes
  has created_at, updated_at, downloads

  # delta indexing
  set_property :delta => true

  # weighting fields
  set_property :field_weights => {
    :name => 10,
    list_of_tags => 6,
    author => 5,
    description => 4,
  }

end

正常范围:

scope :approved, where(:approved => true)

sphinx范围:

sphinx_scope(:approval_scope) {
  {:conditions => {:approved => "true"}}
}

批准是一个布尔字段,但是,由于我将其索引为字段,所以我相信它的值被视为字符串。无论如何,让 sphinx 范围的值为“true”或 true 没有什么区别 - 与 Theme.approval 不同,Theme.approval_score 仍然返回 0 个结果。我希望我错过了一些简单的事情..

I'm trying to create a simple scope that sphinx will index (Ruby on Rails). The normal scope returns what it should, the sphinx scope returns no results.

define_index do
  # fields
  indexes :name
  indexes author
  indexes description
  indexes list_of_tags
  indexes approved

  # attributes
  has created_at, updated_at, downloads

  # delta indexing
  set_property :delta => true

  # weighting fields
  set_property :field_weights => {
    :name => 10,
    list_of_tags => 6,
    author => 5,
    description => 4,
  }

end

normal scope:

scope :approved, where(:approved => true)

sphinx scope:

sphinx_scope(:approval_scope) {
  {:conditions => {:approved => "true"}}
}

Approved is a boolean field, however, since I'm indexing it as a field, I believe its value is treated as a String. Regardless, letting the value of the sphinx scope be "true" or true makes no difference - Theme.approval_score still returns 0 results unlike Theme.approval. I hope I'm missing something simple..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2024-12-19 17:50:43

进行批准

define_index do
  # fields
  ...
  has approved
  ...
end

然后

sphinx_scope(:approval_scope) {
  {:with => {:approved => true}}
}

make the approved with has

define_index do
  # fields
  ...
  has approved
  ...
end

then

sphinx_scope(:approval_scope) {
  {:with => {:approved => true}}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文