我想在数十亿个字符串中进行一般的子字符串搜索。这个要求与一般的全文搜索有点不同,因为我想要一个查询“ubst”也可以点击“substr”。
Lucene 或 Sphinx 有能力做到这一点吗?如果不是,您认为最好的方法是什么?
我想在数十亿个字符串中进行一般的子字符串搜索。这个要求与一般的全文搜索有点不同,因为我想要一个查询“ubst”也可以点击“substr”。
Lucene 或 Sphinx 有能力做到这一点吗?如果不是,您认为最好的方法是什么?
这种情况下最好的索引结构是后缀树 Lucene 没有实现这种类型的索引,所以它的子字符串搜索很慢。但是 lucene 具有前缀树索引,这意味着如果您通过前缀搜索术语,您可以进行快速搜索。
Lucene is one of the best available options. Lucene supports sub string search so ubst will return substr.
check out http://wiki.apache.org/lucene-java/LuceneImplementations for suitable language implementation.
自 2011 年 4 月 22 日版本 2.0.1-beta 起,Sphinx确实支持有效的子字符串搜索。不幸的是,截至今天,此支持仅涉及 beta 版本,如此处所述。
我尝试了 2.1.1 beta 版本。它似乎工作正常。请参阅字典类型的手册条目,阅读keywords
类型。
当我尝试使用 2.0.6 发布版本时,它又回到了低效的 crc 索引,在索引过程中给出了以下警告:
WARNING: min_infix_len is not supported yet with dict=keywords; using dict=crc
我的最小配置文件:
source sour
{
type = xmlpipe2
xmlpipe_command = type C:\Temp\1\sphinx\input.xml
}
index inde
{
source = sour
path = testpa
enable_star = 1
dict = keywords
charset_type = utf-8
min_infix_len = 1
}