【问题标题】:Build an index for substring search?为子字符串搜索建立索引?
【发布时间】:2011-10-13 21:35:27
【问题描述】:

我想在数十亿个字符串中进行一般的子字符串搜索。这个要求与一般的全文搜索有点不同,因为我想要一个查询“ubst”也可以命中“substr”。

Lucene 或 Sphinx 能够做到这一点吗?如果不是,您认为最好的方法是什么?

【问题讨论】:

    标签: full-text-indexing


    【解决方案1】:

    这种情况下的最佳索引结构是suffix tree Lucene 没有实现这种类型的索引,所以它的子字符串搜索很慢。但是 lucene 具有前缀树索引,这意味着如果您通过前缀搜索词条,您可以进行快速搜索。

    【讨论】:

    • 谢谢。我自己建了一个后缀数组。
    【解决方案2】:

    Lucene 是最好的选择之一。 Lucene 支持子字符串搜索,所以 ubst 会返回 substr。

    查看http://wiki.apache.org/lucene-java/LuceneImplementations 了解合适的语言实现。

    【讨论】:

    • 谢谢,但Lucene似乎没有索引。
    【解决方案3】:

    Sphinx 自 2011 年 4 月 22 日版本 2.0.1-beta 起支持有效的子字符串搜索。不幸的是,截至今天,此支持仅涉及 beta 版本,如 here 所述。

    我尝试了 2.1.1 beta 版本。它似乎工作正常。字典类型见manual entry,阅读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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-08
      • 1970-01-01
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      • 2011-09-27
      相关资源
      最近更新 更多