开发者

How to get IndexReader from custom request handler?

开发者 https://www.devze.com 2023-04-11 21:34 出处:网络
This is extension of my earlier question. I\'m going to create custom request handler to provide terms association mining over existing index. In order to do this I need access to Solr\'s IndexReade

This is extension of my earlier question.

I'm going to create custom request handler to provide terms association mining over existing index. In order to do this I need access to Solr's IndexReader opened on default index directory.

The only way to do this I can think of is to get IndexReaderFactory by invoking SolrQueryRequest.getCore().getIndexReaderFactory(). This factory has method newReader() which seems to be what I need. But this method requires index directory as its first argument.

Here's my question: is it correct way to get IndexReader? If so, how can I get Solr's index directory? Can 开发者_运维技巧I access Solr configuration to find it from my code or should I go with something else?


I found an answer myself while reading LukeRequestHandler source:

SolrIndexSearcher searcher = req.getSearcher();
IndexReader reader = searcher.getReader();

So they first get searcher, and only then reader.

0

精彩评论

暂无评论...
验证码 换一张
取 消