Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically generate indexes #2

Open
pivotal-casebook opened this issue Jan 19, 2011 · 6 comments
Open

Automatically generate indexes #2

pivotal-casebook opened this issue Jan 19, 2011 · 6 comments

Comments

@pivotal-casebook
Copy link

We should have a rake task that generates indexes where possible.

For dynamic scopes it will be difficult to generate indexes. Perhaps there can be some sort of way to call into a dynamic scope with the options you use for a typical search and have it generate an index instead of results.

@alexhanh
Copy link

It would be nice to have some guidance, such as a wiki page, describing how to manually setup the indexes until it's automated.

@nertzy
Copy link
Collaborator

nertzy commented Jun 1, 2011

Agreed. I will get a wiki page up soon.

@elfassy
Copy link

elfassy commented Jun 26, 2012

+1

1 similar comment
@ciastek
Copy link

ciastek commented Jul 20, 2012

+1

@dlikhten
Copy link

Here's an index for the multisearch table which works with the configuration:

PgSearch.multisearch_options = {
    using: {
        tsearch: {
            prefix: true
        }
    }
}

Basically everything inside the gin(...) is what is generated by pg_search, so this should go into the multi-search table and can be auto generated once the user decides how multi-search is to be globally used.

The only problem (which cannot really be auto-solved) is if the user changes configuration, they also need to change the index.

CREATE INDEX pg_multisearch_index 
ON pg_search_documents 
USING gin(to_tsvector('simple', coalesce("content"::text, '')))

@nertzy
Copy link
Collaborator

nertzy commented Sep 13, 2013

Thanks, @dlikhten, that looks like a reasonable index for that configuration. You should ensure that your important queries actually use the index by looking through output from EXPLAIN or EXPLAIN ANALYZE. http://www.postgresql.org/docs/current/static/sql-explain.html

For now, we have a wiki page that can help guide people to design their indexes. https://github.com/Casecommons/pg_search/wiki/Building-indexes

NikoRoberts pushed a commit to NikoRoberts/pg_search that referenced this issue Jun 26, 2018
* Fix the spec `where rank > 0.7` by different logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants