This repository was archived by the owner on Aug 31, 2025. It is now read-only.
Conversation
this commit is an attempt at building a search functionality using only
the stuff provided by postgresql
it is, unfortunately, painfully slow:
PgSearch::Document Load (7869.1ms) SELECT "pg_search_documents".* FROM "pg_search_documents" INNER JOIN (SELECT "pg_search_documents"."id" AS pg_search_id, (ts_rank((to_tsvector('simple', coalesce("pg_search_documents"."content"::text, ''))), (to_tsquery('simple', ''' ' || 'awoo' || ' ''')), 0)) AS rank FROM "pg_search_documents" WHERE ((to_tsvector('simple', coalesce("pg_search_documents"."content"::text, ''))) @@ (to_tsquery('simple', ''' ' || 'awoo' || ' ''')))) AS pg_search_ce9b9dd18c5c0023f2116f ON "pg_search_documents"."id" = pg_search_ce9b9dd18c5c0023f2116f.pg_search_id ORDER BY pg_search_ce9b9dd18c5c0023f2116f.rank DESC, "pg_search_documents"."id" ASC LIMIT $1 [["LIMIT", 10]]
this thing is way too fast! only downside is that indexing takes a bit longer, and the search indexes are big (16Gi for 2.7 million records) i have no idea how to properly integrate it in the UI, but it seems promising :^)
f4d1a1f to
44871cb
Compare
nilsding
commented
Oct 22, 2023
| @results = if params[:multi_search] == "1" | ||
| multi_search_experiment | ||
| else | ||
| [*Answer.search(@query), *Question.search(@query)] |
Member
Author
There was a problem hiding this comment.
doesn't take too long tbh (~2.7m documents)
19:52:10 search.1 | [2023-10-22T17:52:10Z INFO actix_web::middleware::logger] ::1 "POST /indexes/Answer/search HTTP/1.1" 200 959 "-" "Meilisearch Rails (v0.10.1);Meilisearch Ruby (v0.25.1)" 0.023072
19:52:10 search.1 | [2023-10-22T17:52:10Z INFO actix_web::middleware::logger] ::1 "POST /indexes/Question/search HTTP/1.1" 200 933 "-" "Meilisearch Rails (v0.10.1);Meilisearch Ruby (v0.25.1)" 0.011066
nilsding
commented
Oct 22, 2023
| return if @query.blank? | ||
|
|
||
| @results = if params[:multi_search] == "1" | ||
| multi_search_experiment |
Member
Author
There was a problem hiding this comment.
here's the same thing (~2.7m documents), but combined in the same request:
19:52:44 search.1 | [2023-10-22T17:52:44Z INFO actix_web::middleware::logger] ::1 "POST /multi-search HTTP/1.1" 200 2787 "-" "Meilisearch Rails (v0.10.1);Meilisearch Ruby (v0.25.1)" 0.002295
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
super early WIP, resolves #13
this requires Meilisearch to be installed. it's ridiculously fast and super easy to use. eats up a lot of disk space however but i guess that's what it takes to have a decent search.
to set it up locally (macOS):
to enable search functionality:
to import data to meilisearch:
what's still left to be done:
/@user/questions/search//@user/searchpages too which only searches for the user's qustions/answers