Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite3 FTS: Limiting length of items between two words in match request?

I have a table called "topic_overview" that has an "topic_id" field and an "overview" field. The overview contains text descriptions of a topic(that related the id of the topic).

I am trying to figure out how to list the ids of the topics so that they contain the terms “word_1” and “word_2” in the overview field with not more than 5 intervening terms in between.

This is what I've done so far (i'm have a hard time figuring out what the syntax is for limiting the amount of items between word_1 and word_2 to 5):

    SELECT id FROM topic_overview
    WHERE overview match 'word_1 AND word_2';
like image 322
OmicronAlpha Avatar asked Mar 14 '23 09:03

OmicronAlpha


1 Answers

Use NEAR query

SELECT id FROM topic_overview
WHERE overview match 'word_1 NEAR/5 word_2';
like image 173
Ulugbek Umirov Avatar answered Apr 06 '23 08:04

Ulugbek Umirov