retrospring/app/views/search/index.haml
Georg Gadinger c14bae74d5 attempt to add pg_search
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]]
2023-10-22 18:13:26 +02:00

23 lines
787 B
Text

.container-lg.container--main
.row
.col-sm-10.col-md-10.col-lg-9.mx-auto
.card
.card-body
= bootstrap_form_tag layout: :inline, method: :get do |f|
= f.text_field :q, skip_label: true, append: f.primary("Search")
- unless @results.blank?
.container-lg.container--main
.row
.col-sm-10.col-md-10.col-lg-9.mx-auto
- @results.each do |result|
- case result.searchable
- when Answer
= render "answerbox", a: result.searchable, display_all: false, subscribed_answer_ids: []
- when Question
= render "shared/question", q: result.searchable, type: nil
= render 'shared/links'
:ruby
provide(:title, generate_title('Search'))
parent_layout 'base'