如何在Katta中使用FieldCache,FieldCache期望IndexReader作为参数,然后如何从Katta API获取IndexReader。在katta中,LuceneClient.java中的搜索方法返回命中结果。从这个列表中我可以得到每个命中的docId,但我需要Katta中docId的特定字段值。请给我一些编码的例子。
发布于 2011-03-10 19:41:01
我从来没有使用过Katta,我使用过Solr,如果我必须通过它的id来获取文档,并且我只能使用Lucene类,我会使用org.apache.lucene.search.IndexSearcher
// when you figure out how to get IndexReader using Katta API, you'll be able to get the searcher
IndexSearcher searcher = new IndexSearcher(indexReader);
org.apache.lucene.document.Document doc = searcher.doc(docId);
String yourFieldValue = doc.get("yourFieldName");发布于 2013-03-09 00:59:56
您不能在客户端使用FieldCache,因为IndexReader位于服务器端!但是您可以通过LuceneClient上的getDetails()方法获取字段值。
final Hits hits = client.search(query, new String[] { INDEX_NAME }, 10);
for (final Hit hit : hits.getHits()) {
final MapWritable details = client.getDetails(hit, new String[] { "path" });
details.get(new Text("path"));HTH约翰尼斯
https://stackoverflow.com/questions/5256480
复制相似问题