【问题标题】:Is there any way to extract all the tokens from solr?有没有办法从 solr 中提取所有令牌?
【发布时间】:2011-07-14 07:05:58
【问题描述】:

如何从 solr 中提取所有标记?不是来自一个文档,而是来自 solr 中索引的所有文档?

谢谢!

【问题讨论】:

    标签: lucene solr


    【解决方案1】:

    你可以做这样的事情(这个示例被批准用于 lucene 4.x 索引):

    IndexSearcher isearcher = new IndexSearcher(dir, true);
    IndexReader reader = isearcher.getIndexReader();
    Fields fields = MultiFields.getFields(reader);
    Collection<String> cols = reader.getFieldNames(IndexReader.FieldOption.ALL);
    for (String col : cols) {
    Terms te = fields.terms(col);
    if (te != null) {
        TermsEnum tex = te.getThreadTermsEnum();
        while (tex.next() != null)
            // do something 
            tex.getTerm().text();
        }
    }
    

    这将遍历所有列以及每个列的每个术语。您可以查找 TermsEnum 提供的方法,例如 getTerm()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 2019-06-07
      • 2015-04-13
      • 1970-01-01
      相关资源
      最近更新 更多