【问题标题】:Advice on reading indexes阅读索引的建议
【发布时间】:2010-06-05 17:40:15
【问题描述】:

我试图找出在多次运行应用程序时只读取一次 lucene 索引的正确方法,我该如何在 java 中做到这一点?

由于索引数据不会更改,因此无需每次都读取它们。有人可以解释一下它只阅读一次的逻辑吗?谢谢

更新:

public List initTableObject() throws IOException {
        Directory fSDirectory = FSDirectory.open(new File(INDEX_NAME));
        List<String>termList = new ArrayList<String>();

        RAMDirectory directory = new RAMDirectory(fSDirectory);

        IndexReader iReader = IndexReader.open(fSDirectory);
        FilterIndexReader fReader = new FilterIndexReader(iReader);



    //  int numOfDocs = fReader.numDocs();
        TermEnum terms = fReader.terms(); 


        while (terms.next()){
            Term term = terms.term(); 
            String termText = term.text();
            termList.add(termText);
            }
            iReader.close();
            return termList;
    }

我对 lucene 和这个真的很陌生,所以这就是我到目前为止所得到的,我只是还没有使用 RAMDirectory。

此方法检索列表,因为我需要此索引列表与我拥有的一些文件进行比较。如何将此列表存储到 RAM 中,以便在应用程序的其他部分中使用它进行比较?

【问题讨论】:

    标签: java lucene


    【解决方案1】:

    我认为this question 上的答案可能有用。

    【讨论】:

      猜你喜欢
      • 2018-10-12
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 1970-01-01
      • 2017-11-01
      相关资源
      最近更新 更多