0

Not sure if this is possible, and thus far a series of creative google searches have yielded nothing, however...

I have decent size database with a column “article” that contains up to around a thousand word per row. Surprisingly doing an FTS on that index is very fast and am happy with the speed. What I would like to do is to return the match and surrounding text only not the entire content.

For example if I was searching for the word “daylight” across the index then I would expect to get all the rows where the “article” column contains the word “daylight” (all good so far), the problem is that in each of these rows the “article” column could be a thousand words long so times that by 100 results and that is a big return. It would be great if for each of those matches I could return that word and the previous x amount of chars and the following x amount of chars in the “article” column instead of all the content the column contains.

Is this possible in MySQL? If not what else could I use?

Kirk
  • 11
  • 3
  • The biggest problem i see that a search with 'left right' IN NATURAL LANGUAGE MODE would return all rows that those words occur, but what text surrounding which word do you want to show? – nbk Oct 13 '19 at 00:15
  • This task is more for the presentation layer, rather than for the db layer. – Shadow Oct 13 '19 at 00:40
  • Hey Shadow, I understand it’s better suited to the presentation layer but as mentioned I could be pulling hundreds of rows containing thousands of words in each row. This is not efficient enough so need to done at an SQL level. – Kirk Oct 13 '19 at 06:24

0 Answers0