mysql - extract specific words from text field using full text search

霸气de小男生 提交于 2019-12-25 08:37:09

问题


My question is a little simillar to Extract specific words from text field in mysql, but now the same.

I have a text field with words inside. In my language word can have many different endings. I need to find this endings.

I use fulltext search of mysql, but I would need to have access to the index database where all the field is "cut" to words and words are counted. I could then search for "test*" and I could quickly find "test", "tested", "testing". I need the list of all endigns that exist in my database, that is my primary goal.

As it is I can get the records with specific "test*" words in it, but I need not only to locate the occurence in the field, but to group somehow so I get the list of all the words that for example start with "test". I don't need location in which record they are, just a list, grouped so that "testing" is not written 10 times but only once (maybe a counter of how many times it is found but not necessary).

Is there a way to extract this info from fulltextsearch field or should I explode all this fields to words and make a index table full of words and just do a "like "word%" and group by the different results? I am not sure how to do that either in practice, but just to point me to the right direction please.

So to summarize: I have a text fied and I need to find out which words are inside that start with "test", like "tested", "test", "testing" etc... It doesn't make sense in English but in my language it does as we have same word on different endigns and there are so many of them, somethimes 20, I need to find out which ones are there so I can make a synonims table ;-)

UPDATE:

Database has columns ID (int), ingredients (text) and recipe (text).

Data in ingredients are cooking ingredients with different endings like:

1 egg 2 eggs

etc.


回答1:


You can dump all words that are present in an index. And that would also show frequency of each word. E.g. test is used 200 times and testing is used 300 times.

Manual for that: http://dev.mysql.com/doc/refman/5.0/en/myisam-ftdump.html



来源:https://stackoverflow.com/questions/5712729/mysql-extract-specific-words-from-text-field-using-full-text-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!