读书人

solr DocumentCache的有关问题

发布时间: 2012-09-06 10:37:01 作者: rapoo

solr DocumentCache的问题



发现如果不使用Document Cache的时候,solr内部还是会调用两次

第一次,在QueryComponent里会有处理搜索,取得result,除了内部lucene id外,会调用doPrefetch方法,取出doc文档 放在DocumentCache缓存里,


便于下次使用,如果当前没有使用DocumentCache的话,发现还是会调用该方法去拿Document出来。。

solr DocumentCache的有关问题



solr DocumentCache的有关问题

solr DocumentCache的有关问题




responseWriter的时候也会调用doc(int ,Set<String>)方法取Document,如果有使用document Cache的话,可以得到之前已缓存的数据,不用再去索引里取数据,但如果没有用cache的话,就会去查询。这样,会重复调用两次取document数据

solr DocumentCache的有关问题

先看正向取文档时的代码如下:

  protected void doPrefetch(ResponseBuilder rb) throws IOException  {    SolrQueryRequest req = rb.req;    SolrQueryResponse rsp = rb.rsp;    //pre-fetch returned documents    if (documentCache != null&&!req.getParams().getBool(ShardParams.IS_SHARD,false) && rb.getResults().docList != null && rb.getResults().docList.size()<=50) {      // TODO: this may depend on the highlighter component (or other components?)      SolrPluginUtils.optimizePreFetchDocs(rb.getResults().docList, rb.getQuery(), req, rsp);    }  }






读书人网 >互联网

热点推荐