Questions tagged [pg-search]

Ruby gem that builds ActiveRecord named scopes that take advantage of PostgreSQL's full text search.

pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL's full text search.

203 questions
5
votes
1 answer

How to enable :tsearch dictionary for pg_search multi-search?

I'm adding pg_search into a Rails app. I'm following the instructions on github and this railscast, but I've run into a problem. I'm setting up a multi model search, and I have a basic implementation working. But I want to extend pg_seach to use its…
Andy Harvey
  • 12,333
  • 17
  • 93
  • 185
4
votes
3 answers

rails - Search Controller

I'm getting ready to build search capabilities into my app. I want the search to have the ability to span multiple models. I'm thinking about adding a search controller which would then decide which models to search based on settings etc... What do…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
4
votes
1 answer

pg_search: Using a dynamic method as the against parameter

According to the accepted answer of this question, you should be able to use the return value of a instance method as the against parameter... class Car < ActiveRecord::Base include PgSearch multisearchable :against => [:name,…
BrightBlue
  • 417
  • 4
  • 11
4
votes
1 answer

Postgresql trigram text search with pg_search results order

I implemented a trigram search using pg_search gem on rails. https://github.com/Casecommons/pg_search The problem is that sometimes the order of returned results doesn't seems right according to the definition of the trigram search that shows the…
Mono
  • 302
  • 2
  • 6
  • 21
4
votes
1 answer

PG full text search on rails using pg_search gem for substring

I am using Pg full text search for my search . As i am using Ruby on rails, I am using pg_search gem. How do i configure it to give a hit for substring as well. pg_search_scope :search_by_detail, :against => [ …
yatish mehta
  • 905
  • 1
  • 10
  • 25
3
votes
1 answer

Rails AMS, specify different serializers in polymorphic list

I implemented a multi-table search using pg_search, and then serialize the result with Active Model Serializer (version 0.10) - it works fine, but AMS uses the default serializer for each of the types returned. Here's the serializer: class…
3
votes
1 answer

How to use tsvector_update_trigger with array types in PostgreSQL?

I'm using the pg_search gem to add full text search to a table in my app. My problem is when trying to create a trigger to keep the tsv column up to date after any change, this is my migration: class AddStoreItemsIndex <…
Carlos Martinez
  • 4,350
  • 5
  • 32
  • 62
3
votes
2 answers

PG_SEARCH gem search specific columns only for JSON

I have jsonb column in my postgres table and i want to search only one key not all the keys. e.g. Book.create!(details: {authour: 'example', title: 'something'} class Book < ApplicationRecord include PgSearch pg_search_scope :search, …
sethi
  • 1,869
  • 2
  • 17
  • 27
3
votes
1 answer

pg_search dmetaphone not working after installing contrib package

After installing pq_search and running contrib package migration: class InstallSomeContribPackages < ActiveRecord::Migration def up execute 'CREATE EXTENSION pg_trgm;' execute 'CREATE EXTENSION fuzzystrmatch;' end def down execute…
Babbz77
  • 283
  • 3
  • 18
3
votes
1 answer

Search special characters with pg_search

Im using pg_search And trying to search in the title for a special character. For example, I have two rows with this information: id title 1 GT40 2 #GT40 So when I search "#GT40", the result with pg_search will be 1 and 2. But I want…
sebaMelgar
  • 97
  • 12
3
votes
0 answers

Postgres full-text search with synonyms and near by words

I have a database of products which I do a full-text search on using pg_search Gem. The query looks something like this: SELECT "products".* FROM "products" WHERE (((to_tsvector('english', coalesce("products"."description"::TEXT, ''))) …
3
votes
2 answers

Postgres full text search using pg_search - includes(:child_model) breaks the SQL with 'missing FROM-clause entry for table 'child_model'

I'm using postgres full text search with the pg_search gem. The search itself is working well, but I need to further filter the results and here are the details: class Notebook < ActiveRecord::Base has_many :invites def self.text_search(query) …
kaustubhb
  • 399
  • 1
  • 5
  • 19
3
votes
1 answer

How to write a model spec to test PgSearch text_search query method (Rspec, Rails, Postgres)

I'm trying to write a couple of tests in my model spec testing that the following method's logic works whether a query is passed in or not. models/payment.rb include PgSearch pg_search_scope :search, :against =>…
chhhris
  • 355
  • 1
  • 4
  • 16
3
votes
0 answers

How do I configure pg_search to search against an attribute via delegation in Rails?

I have a User model that gets attributes such as first_name, last_name, etc... via a delegation to a Profile model: delegate :first_name, :last_name, to: :profile I want to be able to search for another model, Services, which…
ptwiggerl
  • 301
  • 4
  • 7
3
votes
2 answers

Adding Prefix Match to pg_search

I am following this Railscasts episode. If I search "Kerber" it does return the right article. But if I search "Ke" it does not returns the same article. There's a way to fix this? class Item < ActiveRecord::Base include PgSearch …
Sullivan
  • 55
  • 6
1 2
3
13 14