MySQL search
Add a single search_index table for full-text search of cards and comments. For the search there is a full-text index on the title and content columns. The board_ids is also included in the table and accessible board ids are pre-loaded and included in the search query. This allows us to filter out inaccessible records before joining with other tables. Right now the search is just using boolean search. This would give us a bunch of syntax options (see https://dev.mysql.com/doc/refman/8.4/en/fulltext-boolean.html) except the search query filters those out. I've removed the searchable_by method for now - everything is built on the assumption that there's a single search index table and all data must fit into it. Queries are written in SQL, we don't have a SearchIndex ActiveRecord model. That's because we'll likely want to shard the table and it will be simpler to just keep with the raw SQL for that. There's no stemming, highlighting or snippet extraction yet - we are dumping the full description in the search results. Data can be reindexed with the search:reindex rake task.
This commit is contained in:
committed by
Mike Dalessio
parent
c557f1424b
commit
e8abc66eba
Generated
+13
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.2].define(version: 2025_11_11_153019) do
|
||||
ActiveRecord::Schema[8.2].define(version: 2025_11_12_093037) do
|
||||
create_table "accesses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.datetime "accessed_at"
|
||||
t.bigint "board_id", null: false
|
||||
@@ -375,6 +375,18 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_11_153019) do
|
||||
t.index ["reacter_id"], name: "index_reactions_on_reacter_id"
|
||||
end
|
||||
|
||||
create_table "search_index", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "board_id", null: false
|
||||
t.bigint "card_id", null: false
|
||||
t.text "content"
|
||||
t.datetime "created_at", null: false
|
||||
t.bigint "searchable_id", null: false
|
||||
t.string "searchable_type", null: false
|
||||
t.string "title"
|
||||
t.index ["content", "title"], name: "index_search_index_on_content_and_title", type: :fulltext
|
||||
t.index ["searchable_type", "searchable_id"], name: "index_search_index_on_searchable_type_and_searchable_id", unique: true
|
||||
end
|
||||
|
||||
create_table "search_queries", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.string "terms", limit: 2000, null: false
|
||||
|
||||
Reference in New Issue
Block a user