MySQL has JSON functions that you can use to query JSON data. In your case, you can use the JSON_CONTAINS() function to search in the tags column. Here is an example:
SELECT * FROM psTextPages WHERE JSON_CONTAINS(tags, '"tag 1"');
This will return all rows where the tags column contains "tag 1".
As for indexing, MySQL does not support indexing on JSON columns directly. However, you can create a generated column that extracts a scalar value from the JSON column, and then index the generated column.
Here is an example:
ALTER TABLE psTextPages ADD COLUMN tags_extracted AS (JSON_UNQUOTE(JSON_EXTRACT(tags, '$[0]')));
CREATE INDEX idx_tags ON psTextPages(tags_extracted);
In this example, tags_extracted is a generated column that extracts the first tag from the tags JSON array. Then, an index is created on this generated column.
Please note that this approach has its limitations. It only indexes the first tag in the JSON array. If you need to index all tags, you might need to reconsider your database design. For example, you could create a separate table for tags and use a many-to-many relationship between pages and tags. This would allow you to index and search tags more efficiently.