包装全文查询语法
Crate fulltext query syntax
我正在考虑从 Sphinx 迁移到 Crate,但我找不到任何关于全文查询语法的文档。在 Sphinx 中我可以搜索:
("black cat" -catalog) | (awesome creature)
这代表文档中任何确切的短语 "black cat" 和没有术语 "catalog" 或文档
中任何位置的 "awesome" 和 "creature"
black << big << cat
这要求文档包含所有 "black"、"big" 和 "cat" 项,还要求 "black" 的匹配位置小于 [=31= 的匹配位置]等等。
而且我需要在文档中的特定位置进行搜索。在狮身人面像中,我能够按如下方式使用邻近运算符
hello NEAR/10 (mother|father -dear)
这要求文档包含 "hello" 术语和 "mother" 或 "father" 术语最多与 "hello" 相距 10 个术语,并且术语 "dear" 不得接近 "hello"
的 10 项
我的应用程序大量使用了 NEAR 的最后一个构造。这一切都可以在 Crate 中实现吗?
不幸的是,我无法评论它与 Sphinx 相比如何,但我会坚持你的问题:)
Crate's fulltext 搜索自带 SQL 和 Lucene 的匹配能力,因此应该能够处理复杂的查询。我将只提供与您的输出相匹配的查询,我认为它应该非常易读。
("black cat" -catalog) | (awesome creature)
select *
from mytable
where
(match(indexed_column, 'black cat') using phrase
and not match(indexed_column, 'catalog'))
or match(indexed_column, 'awesome creature') using best_fields with (operator='and');
black << big << cat
select *
from mytable
where
match(indexed_column, 'black big cat') using phrase with (slob=100000);
这个有点棘手,似乎没有一个运算符与 Sphinx 中的完全相同,但可以用 "slop" 值进行调整。根据用例,可能还有另一个(更好的)解决方案...
hello NEAR/10 (mother|father -dear)
select *
from mytable
where
(match(indexed_column, 'hello mother') using phrase with (slop=10)
or match(indexed_column, 'hello father') using phrase with (slop = 10))
and not match(indexed_column, 'hello dear') using phrase with (slop = 10)
与 Sphinx 的语言相比,它们可能看起来有点笨拙,但它们工作得很好 :)
在性能方面,它们应该仍然非常快,感谢 Lucene..
干杯,克劳斯
我正在考虑从 Sphinx 迁移到 Crate,但我找不到任何关于全文查询语法的文档。在 Sphinx 中我可以搜索:
("black cat" -catalog) | (awesome creature)
这代表文档中任何确切的短语 "black cat" 和没有术语 "catalog" 或文档
中任何位置的 "awesome" 和 "creature"black << big << cat
这要求文档包含所有 "black"、"big" 和 "cat" 项,还要求 "black" 的匹配位置小于 [=31= 的匹配位置]等等。
而且我需要在文档中的特定位置进行搜索。在狮身人面像中,我能够按如下方式使用邻近运算符
hello NEAR/10 (mother|father -dear)
这要求文档包含 "hello" 术语和 "mother" 或 "father" 术语最多与 "hello" 相距 10 个术语,并且术语 "dear" 不得接近 "hello"
的 10 项我的应用程序大量使用了 NEAR 的最后一个构造。这一切都可以在 Crate 中实现吗?
不幸的是,我无法评论它与 Sphinx 相比如何,但我会坚持你的问题:)
Crate's fulltext 搜索自带 SQL 和 Lucene 的匹配能力,因此应该能够处理复杂的查询。我将只提供与您的输出相匹配的查询,我认为它应该非常易读。
("black cat" -catalog) | (awesome creature)
select *
from mytable
where
(match(indexed_column, 'black cat') using phrase
and not match(indexed_column, 'catalog'))
or match(indexed_column, 'awesome creature') using best_fields with (operator='and');
black << big << cat
select *
from mytable
where
match(indexed_column, 'black big cat') using phrase with (slob=100000);
这个有点棘手,似乎没有一个运算符与 Sphinx 中的完全相同,但可以用 "slop" 值进行调整。根据用例,可能还有另一个(更好的)解决方案...
hello NEAR/10 (mother|father -dear)
select *
from mytable
where
(match(indexed_column, 'hello mother') using phrase with (slop=10)
or match(indexed_column, 'hello father') using phrase with (slop = 10))
and not match(indexed_column, 'hello dear') using phrase with (slop = 10)
与 Sphinx 的语言相比,它们可能看起来有点笨拙,但它们工作得很好 :)
在性能方面,它们应该仍然非常快,感谢 Lucene..
干杯,克劳斯