Answer the question
In order to leave comments, you need to log in
How to find a list of exact matches of phrases from a database in a given text using PHP?
There is a database with 100k keywords, such as:
большой дом
кафельная плитка
зеленая машина в саду
В ноябре в Лондоне большой человек купил большой дом для своей большой семьи. В доме была кафельная панель.
большой дом
SELECT * FROM `phrases` WHERE MATCH(`phrase`) AGAINST('В ноябре в Лондоне большой человек купил большой дом для своей большой семьи. В доме была кафельная панель.')
большой дом
кафельная плитка
Answer the question
In order to leave comments, you need to log in
At the moment I settled on a solution of the form:
Functionally, it does exactly what is needed, but the performance of such a request is weak, and it looks more like a crutch. I will try again with sphinxql.
Bloom filter try the
original sort and 2-3-4 word sets and each set - into the filter,
incoming - cut into 4-3-2 and run through the filters
, I think it would be easier to quickly stick the incoming text into the RT Sphinx index and for all phrases
php.net/manual/en/sphinxclient.setmatchmode.php SPH_MATCH_PHRASE
It is necessary to find in this text all full matches from the database.
SELECT *
FROM `phrases`
WHERE
'В ноябре в Лондоне большой человек купил большой дом для своей большой семьи. В доме была кафельная панель.'
LIKE CONCAT('%', phrases.`phrase` , '%')
Tools for such purposes, as far as I know, look something like this:
- all phrases are divided into words, they are searched for a morphological basis
- all words and phrases in which they occur are stored in the database (more precisely, already the id of the word in the word table and the id of the phrase in the phrase repository - the phrase is not necessarily stored there, but it can be restored from there)
- you do the same for the incoming phrase - parse it into words and find phrases in the database in which these words occur.
Then on this rather limited one, you can apply arbitrarily sophisticated search to the sample.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question