Sqlite3 FTS Match Limited to 30 OR operators?

Top of the evening.
I’m building a program where a user can input a number of items, and
if all the items are found in a given recipe, the recipe is returned.
I’m trying to use sqlite3 FTS3 to do this, but I’ve come across a
problem. It seems that only the first 30 items are considered in the

That means, for example, I’m given 30 ingredients, and will get back
17 recipes. Upon adding a 31st ingredient, the query length is
increased to 31 and if the 31’st ingredient was necessary for say, 2
recipes, now only 15 are returned.

My code looks something like

statement = “Select title,
count_ingredients_in_recipe(ingredients_column) as ingredient_count,
count_ingredients_found(ingredients_column) as found_count from
recipe_table where ingredients_column MATCH ‘ing1 OR ing2 OR ing3 OR …
ing30’ AND ingredient_count - found_count <= 0”


This is happy… however when I increase the ingredient count to say 31

in the above example ing31 would now be ignored by the query.

I’ve looked at the operational limits of sqlite and I’m not seeing any
hard limits set to 30 OR operations.

Has anyone seen this, experienced this or know how to increase the

I’ve exhausted the last 8 hours trying to figure this out and I’ve
turned to you all for help!

So in advance, many many thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs