posts: use string_to_array index for tag searches.

Use the `string_to_array(tag_string, ' ')` index instead of the
`tag_index` for tag searches. The string_to_array index lets us treat
the tag_string as an array for searching purposes. This lets us get rid
of the tag_index column and the test_parser dependency in the future.
This commit is contained in:
evazion
2021-10-10 16:34:15 -05:00
parent 51e9ea2772
commit 37a8dc5dbd
4 changed files with 71 additions and 26 deletions

View File

@@ -1132,7 +1132,7 @@ class Post < ApplicationRecord
end
def raw_tag_match(tag)
where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery)
Post.where_array_includes_all("string_to_array(posts.tag_string, ' ')", [tag])
end
# Perform a tag search as an anonymous user. No tag limit is enforced.