-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
add some search functionality #1406
Draft
nilsding
wants to merge
3
commits into
main
Choose a base branch
from
wir-suchen-dich
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
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 :^)
nilsding
force-pushed
the
wir-suchen-dich
branch
from
October 22, 2023 17:51
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)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/search
pages too which only searches for the user's qustions/answers