标签: pg-search

"文本搜索查询不包含lexemes:"是什么意思?

在Rails应用程序中,我正在使用pg_search gem.当我运行我的RSpec套件时,我看到很多行:

NOTICE:  text-search query doesn't contain lexemes: ""
LINE 1: ...e("pg_search_documents"."content"::text, '')))), (''), 0)) A...
Run Code Online (Sandbox Code Playgroud)

我不确定这意味着什么,或者我是否应该关注它.

有人可以帮忙吗?

rspec ruby-on-rails pg-search

10
推荐指数
1
解决办法
980
查看次数

正确的全文索引Rails/PostgreSQL/pg_search

我正在测试PostgreSQL全文搜索(使用pg_search gem)和solr(sunspot_solr gem)的性能.

对于400万条记录,我获得了13456毫秒的Tsearch800毫秒的SOLR(即SOLR查询+ DB回溯).很明显,我需要索引,但我不知道如何创建一个全文搜索.我调查并发现,对于全文搜索,我应该使用GIN索引.

execute "CREATE INDEX products_gin_title ON products USING GIN(to_tsvector('english', title))"
Run Code Online (Sandbox Code Playgroud)

但我正在搜索另外两列,我需要多值索引,我不知道如何实现它?我对DB部分不是很熟悉.我的搜索代码如下:

@results = Product.search_title(params[:search_term]).where("platform_id=? AND product_type=?", params[:platform_id], params[:type_id]).limit(10).all
Run Code Online (Sandbox Code Playgroud)

如何为此类情况创建正确的查询?

这是来自rails的搜索词车的 SQL输出.

Product Load (12494.0ms)
SELECT 
    "products".*, 
    ( ts_rank((to_tsvector('simple', coalesce("products"."title"::text, ''))), (to_ tsquery('simple', ''' ' || 'car' || ' ''')), 2) ) AS pg_search_rank 
FROM "products" 
WHERE (((to_tsvector('simple', coalesce("products"."tit le"::text, ''))) @@ (to_tsquery('simple', ''' ' || 'car' || ' ''')))) 
    AND (platform_id='26' AND product_type='2') 
ORDER BY pg_search_rank DESC, "products"."id" ASC 
LIMIT 10 …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails pg-search

10
推荐指数
1
解决办法
3191
查看次数

使用Rails进行Postgres全文搜索的单词分隔符

我正在使用pg_search在我的模型中进行一些文本搜索.在其他属性中,我有一个url字段.

Unfortuantelly Postgres似乎没有识别/.作为单词分隔符,因此我无法搜索url.

示例:testhttp://test.com中搜索不会产生任何结果.

有没有办法解决这个问题,可能使用另一个gem或一些内联SQL?

postgresql ruby-on-rails pg-search

10
推荐指数
2
解决办法
1485
查看次数

如何使用pg_search对运算符实现高级搜索?

我在我的Node模型上实现了PgSearch,如下所示:

include PgSearch
pg_search_scope :node_search, against: [:name, :user_id, :circa],
    using: { tsearch: { any_word: true} },
    :associated_against => {
      comments: [:message],
      user: [:first_name, :last_name, :email],
      memberships: [:relation]
    }
Run Code Online (Sandbox Code Playgroud)

在我的控制器中我有这个:

if params[:search]
  @nodes = Node.node_search(params[:search])
end
Run Code Online (Sandbox Code Playgroud)

理想情况下,我希望能够做到的是,有人能够键入其中一个关联的文本表示(标志),并且只对该标志进行搜索过滤.

例如:"name:Bouncing Ball",搜索将namenodes模型上调用的列上进行.Aka ...它会查找具有名称的所有节点,Bouncing Ball而不是搜索其他列或模型甚至任何关联.

当然,我希望能够执行以下搜索:( owner: John Brown搜索其所有者/用户first_name和last_name是John Brown comment: Manhattan的所有节点),(搜索所有Manhattan在副本中都有文本注释的节点,等等上.

如何使用PgSearch实现这一目标?

postgresql ruby-on-rails pg-search ruby-on-rails-4

10
推荐指数
1
解决办法
713
查看次数

在Heroku上搜索Rails 3的文本 - Texticle vs acts_as_tsearch vs acts_as_indexed

我正在构建一个将在Heroku上托管的Rails 3应用程序.

要实现全文搜索,这些是我遇到的免费替代方案:

Texticle

acts_as_tsearch

acts_as_indexed

我的应用程序将是数据密集型的,需要大量的读写操作.搜索也将被大量使用.

搜索将跨越不同的模型.

在性能和扩展方面哪一个最好?

还有其他免费和更好的选择吗?

转而使用IndexTank或WebSolr(Heroku 推荐)会更好吗?

提前致谢!

search full-text-search ruby-on-rails heroku pg-search

9
推荐指数
2
解决办法
2464
查看次数

Rails:如何使用PG_Search搜索Act_As_Taggable_On生成的标签?(PostgreSQL系统)

我目前使用Act_as_taggable_on标记和pg_search通过我的PostgreSQL数据库我的Rails搜索3应用程序.

如何使用pg_search搜索act_as_taggable_on gem生成的标签?我可以通过说"Post.find(1).tag_list"来查看帖子的标签,但Post表中没有"tag"列,所以当我运行时

 pg_search_scope :search_by_weight, :against => {:tag_list => 'A', :title => 'B', :content => 'C'} #,:using => [:tsearch => {:prefix => true}] #:trigram, :dmetaphone]
Run Code Online (Sandbox Code Playgroud)

它给了我一个错误,因为Post表中没有Post.tag_list列.当你可以通过点连接器(即mission.tag_list)找到值但表中不存在时,它叫什么?我不知道要输入什么.所以基本上,我如何将不存在的列作为参数传入?

另外,你可能已经注意到我已经注释掉了

 :using => [:tsearch => {:prefix => true}] #:trigram, :dmetaphone]
Run Code Online (Sandbox Code Playgroud)

以上.我似乎无法找到如何为Postgresql安装额外的模块.我在哪里输入CREATE EXTENSION?(使用ubuntu 11.10和postgresql 9.1.3 - >和heroku进行制作)

postgresql search ruby-on-rails ruby-on-rails-3 pg-search

9
推荐指数
1
解决办法
1918
查看次数

无法运行rake db:使用Railscast示例在Rails中为Postgresql迁移tsvector GIN索引

我正在关注Ryan Bates 关于在Rails中使用内置的PostgresQL全文搜索的优秀教程.我目前正在使用pg_search gem un-indexed没问题,但我需要提高性能.我正在使用指定了"英语"字典的tsvector.

我正在使用PostgreSQL版本9.1.4

根据Ryan的说明,我使用此代码运行了一个新的迁移,指定了我想要创建的两个新索引.这是架构首先:

create_table "references", :force => true do |t|
  t.string   "title"
  t.string   "type"
  t.datetime "created_at",         :null => false
  t.datetime "updated_at",         :null => false
  t.string   "public_url"
  t.string   "content_type"
  t.integer  "file_size"
  t.text     "overview"
  t.text     "body"
  t.text     "full_text"
  t.integer  "folder_id"
end
Run Code Online (Sandbox Code Playgroud)

我的迁移看起来像这样:

def up
  execute "create index references_title on references using gin(to_tsvector('english', title))"
  execute "create index references_full_text on references using gin(to_tsvector('english', full_text))"
end

def down
  execute "drop index references_title"
  execute "drop index references_full_text"
end
Run Code Online (Sandbox Code Playgroud)

我也继续在application.rb中取消注释:sql选项

config.active_record.schema_format …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails pg-search postgresql-9.1

9
推荐指数
1
解决办法
1072
查看次数

heroku还有其他搜索选项吗?

我即将推出一个测试网站,而heroku看起来是个不错的选择.让我失望的唯一想法是,Websolr附加组件的唯一搜索选项是$ 20/mth.

我确信Websolr很棒,但是在这个项目的早期阶段,我宁愿不去点那笔费用.

有没有任何免费搜索选项可以与heroku的Blossom(免费)计划结合使用.

我觉得这样的小气鬼!

hosting full-text-search ruby-on-rails heroku pg-search

8
推荐指数
1
解决办法
2176
查看次数

如何在Rails中的关联模型上配置pg_search multisearch?

我正在将pg_search添加到Rails应用程序中.我并不完全理解这种配置,并希望在正确的方向上轻轻推动.

首先,我已经在我的应用程序上或多或少地设置并运行了多模型站点.但我想扩展它以搜索相关模型.

例如,我有制造商,汽车,模型类.目前,如果我搜索"福特",则只返回制造商.我还想返回所有相关的汽车(属于制造商)和模型(属于汽车).

我可以看到如何做一个范围搜索

class Car
  pg_search_scope :manufactured_by, :associated_against => {
    :manufacturer => [:name]
  }
end
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试在多元素上执行此操作,则无效

class Car
  include PgSearch
  multisearchable :against => [:name], 
    :associated_against => {
        :manufacturer => [:name]
      }
end
Run Code Online (Sandbox Code Playgroud)

它不会产生错误,它根本不会获取相关记录.

我有一种感觉,我错过了一些基本的东西,我理解这一切是如何组合在一起的.如果有人能帮助我理解这一点,或者指出一个良好的信息来源,我真的很感激.我已经浏览了github和相关Railscast的信息,但我仍然遗漏了一些东西.

ruby-on-rails pg-search

8
推荐指数
1
解决办法
5951
查看次数

如何删除查询结果的排名

我在stories.rb模型上有以下pg_search范围:

  pg_search_scope   :with_text, 
                    :against => :title, 
                    :using => { :tsearch => { :dictionary => "english" }},
                    :associated_against => { :posts => :contents }
Run Code Online (Sandbox Code Playgroud)

我希望查询返回忽略任何排名的结果(我只关心故事最后更新的日期顺序DESC).我知道这对于大多数查看它的人来说都是一个简单的问题,但是如何关闭pg_search中的排名顺序呢?

pg-search

8
推荐指数
1
解决办法
1394
查看次数