• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MoreLikeThisParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.solr.common.params.MoreLikeThisParams的典型用法代码示例。如果您正苦于以下问题:Java MoreLikeThisParams类的具体用法?Java MoreLikeThisParams怎么用?Java MoreLikeThisParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MoreLikeThisParams类属于org.apache.solr.common.params包,在下文中一共展示了MoreLikeThisParams类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initMlt

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
public SolrQuery initMlt(SolrQuery query, String lang){
    query.set(MoreLikeThisParams.MLT,true);
    query.set(MoreLikeThisParams.BOOST, boost);
    query.set(MoreLikeThisParams.INTERESTING_TERMS, interstingTerms ? 
            MoreLikeThisParams.TermStyle.DETAILS.name() : 
                MoreLikeThisParams.TermStyle.NONE.name());
    query.set(MoreLikeThisParams.MIN_DOC_FREQ,minDocFreq);
    query.set(MoreLikeThisParams.MIN_TERM_FREQ, minTermFreq);
    query.set(MoreLikeThisParams.MIN_WORD_LEN, minWordLength);
    query.set(MoreLikeThisParams.MAX_QUERY_TERMS, maxTerms);
    if(filterQuery != null){
        query.addFilterQuery(filterQuery);
    }
    return query;
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:16,代码来源:MltConfig.java


示例2: MoreLikeThisHelper

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
public MoreLikeThisHelper( SolrParams params, SolrIndexSearcher searcher )
{
  this.searcher = searcher;
  this.reader = searcher.getIndexReader();
  this.uniqueKeyField = searcher.getSchema().getUniqueKeyField();
  this.needDocSet = params.getBool(FacetParams.FACET,false);
  
  SolrParams required = params.required();
  String[] fields = splitList.split( required.get(MoreLikeThisParams.SIMILARITY_FIELDS) );
  if( fields.length < 1 ) {
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, 
        "MoreLikeThis requires at least one similarity field: "+MoreLikeThisParams.SIMILARITY_FIELDS );
  }
  
  this.mlt = new MoreLikeThis( reader ); // TODO -- after LUCENE-896, we can use , searcher.getSimilarity() );
  mlt.setFieldNames(fields);
  mlt.setAnalyzer( searcher.getSchema().getIndexAnalyzer() );
  
  // configurable params
  
  mlt.setMinTermFreq(       params.getInt(MoreLikeThisParams.MIN_TERM_FREQ,         MoreLikeThis.DEFAULT_MIN_TERM_FREQ));
  mlt.setMinDocFreq(        params.getInt(MoreLikeThisParams.MIN_DOC_FREQ,          MoreLikeThis.DEFAULT_MIN_DOC_FREQ));
  mlt.setMaxDocFreq(        params.getInt(MoreLikeThisParams.MAX_DOC_FREQ,          MoreLikeThis.DEFAULT_MAX_DOC_FREQ));
  mlt.setMinWordLen(        params.getInt(MoreLikeThisParams.MIN_WORD_LEN,          MoreLikeThis.DEFAULT_MIN_WORD_LENGTH));
  mlt.setMaxWordLen(        params.getInt(MoreLikeThisParams.MAX_WORD_LEN,          MoreLikeThis.DEFAULT_MAX_WORD_LENGTH));
  mlt.setMaxQueryTerms(     params.getInt(MoreLikeThisParams.MAX_QUERY_TERMS,       MoreLikeThis.DEFAULT_MAX_QUERY_TERMS));
  mlt.setMaxNumTokensParsed(params.getInt(MoreLikeThisParams.MAX_NUM_TOKENS_PARSED, MoreLikeThis.DEFAULT_MAX_NUM_TOKENS_PARSED));
  mlt.setBoost(            params.getBool(MoreLikeThisParams.BOOST, false ) );
  boostFields = SolrPluginUtils.parseFieldBoosts(params.getParams(MoreLikeThisParams.QF));
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:MoreLikeThisHandler.java


示例3: buildShardQuery

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
ShardRequest buildShardQuery(ResponseBuilder rb, String q, String key) {
  ShardRequest s = new ShardRequest();
  s.params = new ModifiableSolrParams(rb.req.getParams());
  s.purpose |= ShardRequest.PURPOSE_GET_MLT_RESULTS;
  // Maybe unnecessary, but safe.
  s.purpose |= ShardRequest.PURPOSE_PRIVATE;
  
  s.params.remove(ShardParams.SHARDS);
  // s.params.remove(MoreLikeThisComponent.COMPONENT_NAME);
  
  // needed to correlate results
  s.params.set(MoreLikeThisComponent.DIST_DOC_ID, key);
  s.params.set(CommonParams.START, 0);
  int mltcount = s.params.getInt(MoreLikeThisParams.DOC_COUNT, 20); // overrequest
  s.params.set(CommonParams.ROWS, mltcount);
  
  // adding score to rank moreLikeThis
  s.params.remove(CommonParams.FL);
  
  // Should probably add something like this:
  // String fl = s.params.get(MoreLikeThisParams.RETURN_FL, "*");
  // if(fl != null){
  // s.params.set(CommonParams.FL, fl + ",score");
  // }
  String id = rb.req.getSchema().getUniqueKeyField()
  .getName();
  s.params.set(CommonParams.FL, "score," + id);
  s.params.set("sort", "score desc");
  // MLT Query is submitted as normal query to shards.
  s.params.set(CommonParams.Q, q);
  
  return s;
}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:MoreLikeThisComponent.java


示例4: initMLTParams

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
@Override
protected ModifiableSolrParams initMLTParams(String filterQuery, int maxResultCount, String query) {
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.set("q", query);
	params.set("fq", filterQuery);
	params.set("mlt", "true");
	params.set("mlt.fl", "tags,collection,name,description");
	params.set("mlt", "true");
	params.set("mlt.count", maxResultCount);
	params.set("mlt.mindf", "1");
	params.set("mlt.mintf", "1");
	params.set(MoreLikeThisParams.QF,"description^17.0 tags^3.0");
	return params;
}
 
开发者ID:learning-layers,项目名称:SocRec,代码行数:15,代码来源:DescriptionTagsWeightedBasedRec.java


示例5: MoreLikeThisHelper

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
public MoreLikeThisHelper( SolrParams params, SolrIndexSearcher searcher )
{
  this.searcher = searcher;
  this.reader = searcher.getIndexReader();
  this.uniqueKeyField = searcher.getSchema().getUniqueKeyField();
  this.needDocSet = params.getBool(FacetParams.FACET,false);
  
  SolrParams required = params.required();
  String[] fields = splitList.split( required.get(MoreLikeThisParams.SIMILARITY_FIELDS) );
  if( fields.length < 1 ) {
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, 
        "MoreLikeThis requires at least one similarity field: "+MoreLikeThisParams.SIMILARITY_FIELDS );
  }
  
  this.mlt = new MoreLikeThis( reader ); // TODO -- after LUCENE-896, we can use , searcher.getSimilarity() );
  mlt.setFieldNames(fields);
  mlt.setAnalyzer( searcher.getSchema().getAnalyzer() );
  
  // configurable params
  
  mlt.setMinTermFreq(       params.getInt(MoreLikeThisParams.MIN_TERM_FREQ,         MoreLikeThis.DEFAULT_MIN_TERM_FREQ));
  mlt.setMinDocFreq(        params.getInt(MoreLikeThisParams.MIN_DOC_FREQ,          MoreLikeThis.DEFAULT_MIN_DOC_FREQ));
  mlt.setMaxDocFreq(        params.getInt(MoreLikeThisParams.MAX_DOC_FREQ,          MoreLikeThis.DEFAULT_MAX_DOC_FREQ));
  mlt.setMinWordLen(        params.getInt(MoreLikeThisParams.MIN_WORD_LEN,          MoreLikeThis.DEFAULT_MIN_WORD_LENGTH));
  mlt.setMaxWordLen(        params.getInt(MoreLikeThisParams.MAX_WORD_LEN,          MoreLikeThis.DEFAULT_MAX_WORD_LENGTH));
  mlt.setMaxQueryTerms(     params.getInt(MoreLikeThisParams.MAX_QUERY_TERMS,       MoreLikeThis.DEFAULT_MAX_QUERY_TERMS));
  mlt.setMaxNumTokensParsed(params.getInt(MoreLikeThisParams.MAX_NUM_TOKENS_PARSED, MoreLikeThis.DEFAULT_MAX_NUM_TOKENS_PARSED));
  mlt.setBoost(            params.getBool(MoreLikeThisParams.BOOST, false ) );
  boostFields = SolrPluginUtils.parseFieldBoosts(params.getParams(MoreLikeThisParams.QF));
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:31,代码来源:MoreLikeThisHandler.java


示例6: getMoreLikeThese

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
NamedList<DocList> getMoreLikeThese(ResponseBuilder rb,
    SolrIndexSearcher searcher, DocList docs, int flags) throws IOException {
  SolrParams p = rb.req.getParams();
  IndexSchema schema = searcher.getSchema();
  MoreLikeThisHandler.MoreLikeThisHelper mltHelper = new MoreLikeThisHandler.MoreLikeThisHelper(
      p, searcher);
  NamedList<DocList> mlt = new SimpleOrderedMap<>();
  DocIterator iterator = docs.iterator();
  
  SimpleOrderedMap<Object> dbg = null;
  if (rb.isDebug()) {
    dbg = new SimpleOrderedMap<>();
  }
  
  while (iterator.hasNext()) {
    int id = iterator.nextDoc();
    int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 5);
    DocListAndSet sim = mltHelper.getMoreLikeThis(id, 0, rows, null, null,
        flags);
    String name = schema.printableUniqueKey(searcher.doc(id));
    mlt.add(name, sim.docList);
    
    if (dbg != null) {
      SimpleOrderedMap<Object> docDbg = new SimpleOrderedMap<>();
      docDbg.add("rawMLTQuery", mltHelper.getRawMLTQuery().toString());
      docDbg
          .add("boostedMLTQuery", mltHelper.getBoostedMLTQuery().toString());
      docDbg.add("realMLTQuery", mltHelper.getRealMLTQuery().toString());
      SimpleOrderedMap<Object> explains = new SimpleOrderedMap<>();
      DocIterator mltIte = sim.docList.iterator();
      while (mltIte.hasNext()) {
        int mltid = mltIte.nextDoc();
        String key = schema.printableUniqueKey(searcher.doc(mltid));
        explains.add(key,
            searcher.explain(mltHelper.getRealMLTQuery(), mltid));
      }
      docDbg.add("explain", explains);
      dbg.add(name, docDbg);
    }
  }
  
  // add debug information
  if (dbg != null) {
    rb.addDebugInfo("moreLikeThis", dbg);
  }
  return mlt;
}
 
开发者ID:europeana,项目名称:search,代码行数:48,代码来源:MoreLikeThisComponent.java


示例7: finishStage

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
@Override
  public void finishStage(ResponseBuilder rb) {
    
    // Handling Responses in finishStage, because solrResponse will put
    // moreLikeThis xml
    // segment ahead of result/response.
    if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS
        && rb.req.getParams().getBool(COMPONENT_NAME, false)) {
      Map<Object,SolrDocumentList> tempResults = new LinkedHashMap<Object,SolrDocumentList>();
      
      int mltcount = rb.req.getParams().getInt(MoreLikeThisParams.DOC_COUNT, 5);
      String keyName = rb.req.getSchema().getUniqueKeyField().getName();
      
      for (ShardRequest sreq : rb.finished) {
        if ((sreq.purpose & ShardRequest.PURPOSE_GET_MLT_RESULTS) != 0) {
          for (ShardResponse r : sreq.responses) {
            log.debug("ShardRequest.response.shard: " + r.getShard());
            String key = r.getShardRequest().params
                .get(MoreLikeThisComponent.DIST_DOC_ID);
            SolrDocumentList shardDocList =  (SolrDocumentList) r.getSolrResponse().getResponse().get("response");

            if (shardDocList == null) {
              continue;
            }
 
            log.info("MLT: results added for key: " + key + " documents: "
                + shardDocList.toString());
//            if (log.isDebugEnabled()) {
//              for (SolrDocument doc : shardDocList) {
//                doc.addField("shard", "=" + r.getShard());
//              }
//            }
            SolrDocumentList mergedDocList = tempResults.get(key);
 
            if (mergedDocList == null) {
              mergedDocList = new SolrDocumentList();
              mergedDocList.addAll(shardDocList);
              mergedDocList.setNumFound(shardDocList.getNumFound());
              mergedDocList.setStart(shardDocList.getStart());
              mergedDocList.setMaxScore(shardDocList.getMaxScore());
            } else {
              mergedDocList = mergeSolrDocumentList(mergedDocList,
                  shardDocList, mltcount, keyName);
            }
            log.debug("Adding docs for key: " + key);
            tempResults.put(key, mergedDocList);
          }
        }
      }

      NamedList<SolrDocumentList> list = buildMoreLikeThisNamed(tempResults,
          rb.resultIds);
     
      rb.rsp.add("moreLikeThis", list);
      
    }
    super.finishStage(rb);
  }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:59,代码来源:MoreLikeThisComponent.java


示例8: getMoreLikeThese

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
NamedList<DocList> getMoreLikeThese(ResponseBuilder rb,
    SolrIndexSearcher searcher, DocList docs, int flags) throws IOException {
  SolrParams p = rb.req.getParams();
  IndexSchema schema = searcher.getSchema();
  MoreLikeThisHandler.MoreLikeThisHelper mltHelper = new MoreLikeThisHandler.MoreLikeThisHelper(
      p, searcher);
  NamedList<DocList> mlt = new SimpleOrderedMap<DocList>();
  DocIterator iterator = docs.iterator();
  
  SimpleOrderedMap<Object> dbg = null;
  if (rb.isDebug()) {
    dbg = new SimpleOrderedMap<Object>();
  }
  
  while (iterator.hasNext()) {
    int id = iterator.nextDoc();
    int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 5);
    DocListAndSet sim = mltHelper.getMoreLikeThis(id, 0, rows, null, null,
        flags);
    String name = schema.printableUniqueKey(searcher.doc(id));
    mlt.add(name, sim.docList);
    
    if (dbg != null) {
      SimpleOrderedMap<Object> docDbg = new SimpleOrderedMap<Object>();
      docDbg.add("rawMLTQuery", mltHelper.getRawMLTQuery().toString());
      docDbg
          .add("boostedMLTQuery", mltHelper.getBoostedMLTQuery().toString());
      docDbg.add("realMLTQuery", mltHelper.getRealMLTQuery().toString());
      SimpleOrderedMap<Object> explains = new SimpleOrderedMap<Object>();
      DocIterator mltIte = sim.docList.iterator();
      while (mltIte.hasNext()) {
        int mltid = mltIte.nextDoc();
        String key = schema.printableUniqueKey(searcher.doc(mltid));
        explains.add(key,
            searcher.explain(mltHelper.getRealMLTQuery(), mltid));
      }
      docDbg.add("explain", explains);
      dbg.add(name, docDbg);
    }
  }
  
  // add debug information
  if (dbg != null) {
    rb.addDebugInfo("moreLikeThis", dbg);
  }
  return mlt;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:48,代码来源:MoreLikeThisComponent.java


示例9: finishStage

import org.apache.solr.common.params.MoreLikeThisParams; //导入依赖的package包/类
@Override
  public void finishStage(ResponseBuilder rb) {
    
    // Handling Responses in finishStage, because solrResponse will put
    // moreLikeThis xml
    // segment ahead of result/response.
    if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS
        && rb.req.getParams().getBool(COMPONENT_NAME, false)) {
      Map<Object,SolrDocumentList> tempResults = new LinkedHashMap<>();
      
      int mltcount = rb.req.getParams().getInt(MoreLikeThisParams.DOC_COUNT, 5);
      String keyName = rb.req.getSchema().getUniqueKeyField().getName();
      
      for (ShardRequest sreq : rb.finished) {
        if ((sreq.purpose & ShardRequest.PURPOSE_GET_MLT_RESULTS) != 0) {
          for (ShardResponse r : sreq.responses) {
            log.debug("ShardRequest.response.shard: " + r.getShard());
            String key = r.getShardRequest().params
                .get(MoreLikeThisComponent.DIST_DOC_ID);
            SolrDocumentList shardDocList =  (SolrDocumentList) r.getSolrResponse().getResponse().get("response");

            if (shardDocList == null) {
              continue;
            }
 
            log.info("MLT: results added for key: " + key + " documents: "
                + shardDocList.toString());
//            if (log.isDebugEnabled()) {
//              for (SolrDocument doc : shardDocList) {
//                doc.addField("shard", "=" + r.getShard());
//              }
//            }
            SolrDocumentList mergedDocList = tempResults.get(key);
 
            if (mergedDocList == null) {
              mergedDocList = new SolrDocumentList();
              mergedDocList.addAll(shardDocList);
              mergedDocList.setNumFound(shardDocList.getNumFound());
              mergedDocList.setStart(shardDocList.getStart());
              mergedDocList.setMaxScore(shardDocList.getMaxScore());
            } else {
              mergedDocList = mergeSolrDocumentList(mergedDocList,
                  shardDocList, mltcount, keyName);
            }
            log.debug("Adding docs for key: " + key);
            tempResults.put(key, mergedDocList);
          }
        }
      }

      NamedList<SolrDocumentList> list = buildMoreLikeThisNamed(tempResults,
          rb.resultIds);
     
      rb.rsp.add("moreLikeThis", list);
      
    }
    super.finishStage(rb);
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:59,代码来源:MoreLikeThisComponent.java



注:本文中的org.apache.solr.common.params.MoreLikeThisParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetaRecoveryContext类代码示例发布时间:2022-05-22
下一篇:
Java TypeNameRequestor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap