There is a MySQL database which has columns: keywords and answer.
In the keywords column contains arrays of keywords in JSON format. It can be both words and phrases, for example:
["test", "test", "test phrase"]
In the answer column provides answers to these key words.
There is a message: "test phrase", as to find her a more appropriate answer, given that we have a question with the key word "phrase" and key phrase "test phrase"?
The first thought is to split the sentence according to the word and look for every answer for "LIKE %test% AND LIKE %phrase%", but in this case, if not in entry "%test%", the base did not return, although I would have to find a match for at least "phrase".