Database Administrators Asked by lares.dk on January 4, 2022
I need to be able to search for compound words like “menneskerettighedsforkæmperens” (the human rights activist’s) and find the words “menneske” (human), “rettighed” (right) and “forkæmper” (activist).
I have all the words (and hundreds of thousands of other words) listed in MySQL, all in separate rows with additional information about each word (like hyphenation, which is what I need the DB to return), but I need to search a lot of words at the same time, which can be painfully slow.
I’m currently using a MySQL database, but willing to switch it out for something better suiting my needs, maybe some kind of NoSQL or elasticsearch. But I haven’t been able to find any examples of how to accomplish what I’m looking for in any other type of databases. So if anyone can help me out, I would really appreciate it.
I would look for a library that specializes in splitting compound words. Search Java, PHP, Perl, etc. SQL is not likely to be involved.
If you must use a database, then consider this for a piece of the algorithm:
SELECT word FROM words
WHERE word < 'menneskerettighedsforkæmperens'
ORDER BY word DESC
LIMIT 5;
That is likely to return a few compound words that begin with 'menneske' and perhaps 'menneske', itself.
In MySQL, that query will be quite fast (assuming an index on word
). You would need some code in addition to a few SQL calls.
Answered by Rick James on January 4, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP