Mediawiki has a table in the database 'text' which contains the page content. It is saved as a [BLOB] file. I would like to run a query to search through all the text on the site to see which pages contain a certain 'string'. How do I run a query to search [blob] files?
You can also call Query Blob Contents to query the contents of a version or snapshot.
BLOB values are treated as binary strings (byte strings). They have the binary character set and collation, and comparison and sorting are based on the numeric values of the bytes in column values.
The Mediawiki markup text is stored in the old_text
field, which is a mediumblob type. You can query it like any other text-based field. MySQL will cast your string into binary for the query. Note that this is a case-sensitive search!
select old_id from text where old_text like "%string%";
If you need case-insensitivity then you need to apply an appropriate character set with a case-insensitive collation to the column:
SELECT old_id from text where CONVERT(old_text USING latin1) like '%STRing%';
Be aware that if your table isn't small these queries will take a long time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With