【问题标题】:SQLite error: FTS expression tree is too large (maximum depth 12)SQLite 错误:FTS 表达式树太大(最大深度 12)
【发布时间】:2016-04-07 17:16:42
【问题描述】:

我正在对一个 sqlite 数据库运行这些精确的全文搜索。除了数字之外,它们都是准确的,我在此处添加了这些数字以供识别:

1) A lot of it is caused by insecurities, issues that can trouble you so much that you end up losing your focus.

2) Surely all this is taken in consideration."

3)Discussing the experience of working with his long-deceased coach, Charlie Hilmann is characteristically fond: "We would spend as many as 10 hours in the field, and we eventually delivered just as much as expected.

4) It was challenging.

5)I realized that it's the greatest thing for me if I can use all of the peculiarity of a given moment within a given context, leverage all the inspiration and push it hard to go beyond.

6) You pull out something from the experience that really makes a difference."

7) Constant reminders of the fearless warriors that Charlie and Garrett used to be are the images and stories, relics of a time when experiencing pain and loss was no more than a requirement for achievement and success.

8) That was just the beginning of a journey, with hope and resolve at the forefront and a hunger toward one goal that I knew I could conquer.

所有这些字符串都逐字存在于数据库中。 100% 匹配。 SQLite 找不到查询 2、4 和 6。我不知道为什么。它可能是行尾的不成对引号(它们存在于存储在数据库中的确切字符串中),但是查询#4 有什么问题?

但让我来到这里的真正问题是查询 #3。它会导致错误:

FTS expression tree is too large (maximum depth 12)

怀疑冒号和引号,我把中间的字符串剪掉了,就在“喜欢”之后,再试一次。我仍然得到错误。为什么?是不是太长了?但查询 #7 更长,不会导致任何错误。事实上,我这里还有其他查询,它们的长度大约是查询 #3 的 10 倍,并且它们有效。

谷歌搜索对我没有多大帮助,我无法理解我在该主题上找到的所有内容。但无论如何,我在 sqlite3.c 中使用选项 SQLITE_MAX_EXPR_DEPTH 0 编译了我自己的 sqlite 库,但似乎没有任何改变。我仍然收到查询 #3 的错误,即使我将它切成两半。

有什么想法吗?

【问题讨论】:

  • 注意:除了将SQLITE_MAX_EXPR_DEPTH设置为0之外,我还将SQLITE_FTS3_MAX_EXPR_DEPTH从12增加到24并重新编译,但错误消息仍然显示"(maximum depth 12)"

标签: sqlite


【解决方案1】:

在 FTS 查询中," 用于短语查询,: 用于指定列名,-(在标准语法中)用于排除标记。 (见documentation。)

特殊字符无论如何都不会被索引(参见tokenizers)。

【讨论】:

  • 好的,但是您是否阅读了我所说的部分,即使我在“喜欢”字之后立即剪切查询#3,我仍然会收到错误,因此不包括冒号和引号?
  • 我不确定我可以/应该为你构建什么样的 MCVE,但我有一个重要发现:它是连字符造成的。当我从“已故”中删除连字符时,问题就消失了。当我在任何有效的字符串中引入连字符时,它们将不再有效并导致同样的错误。
  • 我修改了我的应用程序,以便在将查询提交到 sqlite 之前将连字符替换为空格(“long-deceased”变为“long-deeased”)。错误消失了,似乎正确找到了字符串...
  • 我还使用名为 DB Browser for SQLite 的应用程序打开了数据库,并尝试在那里运行查询。结果:当我提交连字符的部分查询时,一切都按预期工作。当我在该应用程序中包含连字符(“long-deceased”)时,查询返回空。当我用空(“longdeeased”)替换连字符时,查询也返回空。当我像在我的应用程序中那样用空格替换连字符(因此它变成“已故”)时,它按预期工作。所以问题确实出在连字符中,必须在提交查询之前将其删除。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-23
  • 2014-02-03
  • 2011-02-04
  • 2022-01-22
  • 2015-02-12
  • 2016-10-18
相关资源
最近更新 更多