SQLite - NLP, FTS... or trick

Magma

Expert
Licensed User
Longtime User
The title says it all...


Do we really need NLP, Full-Text Search (FTS), or is working with simple keywords enough?


When you have a large database full of content—like user messages—you can truly see the magic of AI. It can provide a perfectly sized text snippet (with a character limit you set) that answers your search query or question precisely.


But this comes with a cost!


Take product databases, for example, with queries like this:


Let's say a user searches for "OIL EXTRA VIRGIN 250ml".
I split the phrase into words (using regex or split), and the SQLite query looks something like:

B4X:
SELECT * FROM products WHERE product LIKE '%" & keywords(0) & "%' 
AND product LIKE '%" & keywords(1) & "%' 
AND product LIKE '%" & keywords(2) & "%' ... ;

There are other approaches to normalize and truncate words, but none of these achieve the naturalness and accuracy that a large language model (LLM) can deliver.


What do you think?
How do you handle product databases, or databases with messages/help texts/books in your systems?
 

Magma

Expert
Licensed User
Longtime User

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't think that you need the prefix wildcard.
If a user searches for OIL then they don't expect "Boiler" to match it.

Your approach might be good enough for a focused dataset such as product names. With larger datasets you need to add many more score factors in order to get reasonable results. A basic text scoring feature, considers the number of terms matched and allows partial matching.
 

Magma

Expert
Licensed User
Longtime User
Do you think FTS can help for resonable? ...or go with keywords... let's say when searching forum or discussions?

any SQL QUERY example can help...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…