How to use FieldCache in Katta, FieldCache expects IndexReader as arguments, then how to get IndexReader from Katta API. And In katta the search method in LuceneClient.java returns Hits. From this I can get List, from that I can able to get each hit's docId, but I need particular field value of the docId in Katta. Please give me some coding example.
Asked
Active
Viewed 264 times
2 Answers
0
you can't use the FieldCache on client side, since the IndexReader is located on the server side! But you can get field-values through the getDetails() method on LuceneClient.
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 Johannes

oae
- 1,513
- 1
- 17
- 23
0
I've never worked with Katta, I worked with Solr and if I had to get document by its id and I had to use only Lucene classes, I'd use 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");

Marko Bonaci
- 5,622
- 2
- 34
- 55
-
thanks for you answer mbonaci, but actually in my question itself i mentioned I can't able to find it... – Nageswaran Mar 10 '11 at 12:41
-
I thought, that by saying this: _I can able to get each hit's docId, but I need particular field value of the docId_ you didn't know how to get field value if you had docId. BTW, I don't want to be rude, but I noticed that you use _can_ and _able_ in the wrong way. You either say that you _aren't able to do something_ or _can't do something_. Those two don't go together well :) – Marko Bonaci Mar 10 '11 at 12:57
-
Isn't Katta similar to Lucandra? I mean there has to be some kind of Directory abstraction in Katta also. – Marko Bonaci Mar 10 '11 at 13:10
-
I'm not sure whether this will help at all, but this is the [Katta thread in Solr](https://issues.apache.org/jira/browse/SOLR-1395?focusedCommentId=12919784&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12919784). And this [Solr Wiki Katta link](http://wiki.apache.org/solr/KattaIntegration), of course. – Marko Bonaci Mar 10 '11 at 23:31