pg_search | pg_search builds ActiveRecord named scopes that take | Application Framework library
kandi X-RAY | pg_search Summary
kandi X-RAY | pg_search Summary
PgSearch builds named scopes that take advantage of PostgreSQL's full text search. Read the blog post introducing PgSearch at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pg_search
pg_search Key Features
pg_search Examples and Code Snippets
Community Discussions
Trending Discussions on pg_search
QUESTION
I have a relatively new Rails 6 app (Rails 6.1.3.1), so there's not a whole lot of customization yet. However, I cannot get session variables to persist.
For example, if I put something like the following in a controller action:
...ANSWER
Answered 2021-Jul-15 at 06:00Ok, found the problem. Turns out that I had copied the setting config.session_store :cache_store
in development.rb
from a different project I had been working on. However, this setting was added as part of the StimulusReflex setup for that other project.
From the StimulusReflex docs:
Cookie-based session storage is not currently supported by StimulusReflex.
Instead, we enable caching in the development environment so that we can assign our user session data to be managed by the cache store.
The default setting for this option is cookie_store
. By changing it to :cache_store
without specifying a cache repo, it implements ActionDispatch::Session::CacheStore and defaults to storing it in Rails.cache
, which uses the :file_store
option, which dumps it in tmp/cache
.
However, further down in development.rb
, there is some conditional logic that assigns config.cache_store
to :null_store
if there is no caching-dev.txt
file. This implements ActiveSupport::Cache::NullStore, which is "a cache store implementation which doesn't actually store anything."
So because I had not enabled caching with rails dev:cache
for this project, the session cache was getting toasted with every request.
LESSON LEARNED: Be very careful when copying config settings from an old project to a new one!
QUESTION
I have set enum task_status as:
...ANSWER
Answered 2021-Apr-29 at 16:27If you want to use enum here, then u need to store your enum values as strings in database. Currently your column task_status
has integer
type. Therefore u can't search with LIKE operator. To resolve it make this change.
QUESTION
I have a project I'm trying to use ruby 3 (previously running with 2.7.2), but couldn't accomplish it.
After updated my gemfile with the ruby version and ran bundle
, I'm receiving this error when trying to access rails c
:
ANSWER
Answered 2021-Jan-08 at 00:14You have spring
in your gemfile, usually hanging consoles and servers are related to that. The webrick
gem was removed from the standard library in Ruby 3, so that's why it needs to be included in your Gemfile.
Re-add webrick
to your Gemfile, do a bundle install, and then stop the background spring server with bin/spring stop
. Then re-run the server.
Your best bet on solving issues with spring would be to head over and read about the gem on the GitHub project page, or opening a new question here on SO.
QUESTION
I'm trying to install the pg_search gem. In the first attempt I did not pay attention to the necessary version of ruby (we are using 2.3.1
and 2.4
was required), in the error message that appeared I was asked to run bundle update
, but it updated pg_search to 2.3.5
which require ruby >= 2.5
. Even though I specified an older version of the gem, it still shows the same message:
ANSWER
Answered 2020-Dec-21 at 13:28Even though I specified an older version of the gem
No, you didn't.
You specified '~> 2.1', '>= 2.1.4'
, which means anything 2.1.4 <= version < 3.0.0
.
By running bundle update
, this installed the latest available version that met your requirements, which was apparently 2.3.5
, not 2.1.4
.
If you need to also specify a constraint to ruby version 2.3.1
, you can also put this in the Gemfile
:
QUESTION
I am using rails (5.0.7.2) for a small project. For tags I choose the acts-as-taggable-on and for search pg_search gems. As I want the tags to be searchable, I first created a folder in the app directory called "utilities". Then I crated a file called "search_tags.rb" in that folder.
The content:
...ANSWER
Answered 2020-Jun-17 at 08:56By default everything in app/
is autoloaded, but in config/application.rb
you could add:
config.autoload_paths += %W(#{config.root}/utilities/)
to include utilities as well. Or you could do it in config/environments/...
to do it on a per environment basis
QUESTION
I'm trying to use pg_search in my Rails application to sort a list of parts based on a query from a user. I've run into some trouble, though -- I can't seem to get correct results from an ascending order search.
Here's my model:
...ANSWER
Answered 2020-Apr-02 at 23:58Try using reorder
instead of order
. reorder
will remove any other ordering defined elsewhere in case that's throwing things off.
QUESTION
I'm currently implementing search functionality in my rails app using pg_search for PostgreSQL full text search. Unfortunately, I'm having a problem with getting the migration to add the tsvector column, GIN INDEX and the TRIGGER in the listings table. The migration runs successfully but doesn't create the things specified in the migration file.
Error when trying to access the tsv column:
...ANSWER
Answered 2020-Mar-22 at 14:05I had the def up and def down defined inside def change. Removing the def change method solved my issue.
QUESTION
I'm using the pg_search_scope
feature of the Ruby pg_search
gem, and I have a Listing model with the following scope:
ANSWER
Answered 2020-Jan-28 at 22:18Cradle => c, cr, cra, rad, adl, dle, le, e
pg_trgm does not ever generate the double-space padded tigram at the end of the word, so the last trigram here is le
, not e
. This weights the beginning of words more than the ending, which is generally a reasonable thing to do.
Cras => c, cr, cra, ras, as, s
Similarly, there is no s
trigram. Also, word_similarity, counter-intuitively, does not force the substring of the right hand argument to align on word boundaries. So it treats 'cras' as if it were 'cra', since that is the higher-scoring substring, so there is no ras
or as
. And since 'cra' is not aligned to a word boundary on the right hand side, it apparently does not make an ra
either.
Maybe you want strict_word_similarity
instead.
QUESTION
I am working on a Rails web app. I have records in a model, called AcademicPaper
that I deleted using the batch action destroy functionality that comes with activeadmin
. Right after I did that, I noticed that there was an error of not found ActiveRecord
for the AcademicPaper
model in the controller method that utilized pg_search
gem.
I realized that the pg_search
was not synched with ActiveRecord
s. Therefore, the solution was for me to run PgSearch::Multisearch.rebuild(AcademicPaper)
in the rails console, which I did, which worked.
My question is: how can I avoid this error in a production environment and maybe rebuild the pg_search
index every time an active_admin
batch action occurs?
ANSWER
Answered 2020-Jan-19 at 03:24Straight from Active Admin Documentation -
If you want, you can override the default batch action to do whatever you want:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pg_search
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page