新手问题 [已解决] 根据 Sunspot 文档配置, 查询 boolean 字段时, 没有查询到任何匹配结果, google 无果, 求指教?

rina · February 29, 2016 · Last by martin91 replied at March 04, 2016 · 1856 hits

sunspot 文档:https://github.com/sunspot/sunspot 配置:

class Project < ActiveRecord::Base
  searchable do
   text :name, :oneword, :description
   integer :category_ids, multiple: true
   integer :city_ids, multiple: true
  boolean :published
 end
end

数据库数据:

 pry(main)> Project.all
  Project Load (2.5ms)  SELECT DISTINCT "projects".* FROM "projects"  WHERE "projects"."deleted_at" IS NULL
=> [#<Project id: 1, name: "baidu", oneword: "Summary", description: "adf", stage: nil, industry: nil, city: "深圳", published: true, created_at: "2016-02-29 03:04:01", updated_at: "2016-02-29 10:30:18", team_story: nil, link: "liuzhen.me", status: "approved", deleted_at: nil>,
 #<Project id: 2, name: "dd", oneword: "dd", description: "ddd", stage: nil, industry: nil, city: "dd", published: false, created_at: "2016-02-29 10:44:23", updated_at: "2016-02-29 10:44:23", team_story: nil, link: "liuzhen.me", status: "drafted", deleted_at: nil>]

执行查询:

 Sunspot.search(Project) do
   with(:published, true)
end.results
D, [2016-02-29T21:03:46.567622 #9580] DEBUG -- :   SOLR Request (43.9ms)  [ path=select parameters={fq: ["type:Project", "published_b:true"], start: 0, rows: 30, q: "*:*"} ]
=> []

先检查索引里的值是否正确。

rina closed this topic. 03 Jan 17:39
rina reopened this topic. 17 Mar 10:31
rina closed this topic. 17 Mar 10:31
You need to Sign in before reply, if you don't have an account, please Sign up first.