当前位置: 首页>>代码示例>>Java>>正文


Java SolrIndexSearcher.QueryCommand方法代码示例

本文整理汇总了Java中org.apache.solr.search.SolrIndexSearcher.QueryCommand方法的典型用法代码示例。如果您正苦于以下问题:Java SolrIndexSearcher.QueryCommand方法的具体用法?Java SolrIndexSearcher.QueryCommand怎么用?Java SolrIndexSearcher.QueryCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.search.SolrIndexSearcher的用法示例。


在下文中一共展示了SolrIndexSearcher.QueryCommand方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CommandHandler

import org.apache.solr.search.SolrIndexSearcher; //导入方法依赖的package包/类
private CommandHandler(SolrIndexSearcher.QueryCommand queryCommand,
                       List<Command> commands,
                       SolrIndexSearcher searcher,
                       boolean needDocset,
                       boolean truncateGroups,
                       boolean includeHitCount) {
  this.queryCommand = queryCommand;
  this.commands = commands;
  this.searcher = searcher;
  this.needDocset = needDocset;
  this.truncateGroups = truncateGroups;
  this.includeHitCount = includeHitCount;
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:CommandHandler.java

示例2: getQueryCommand

import org.apache.solr.search.SolrIndexSearcher; //导入方法依赖的package包/类
/**
 * Creates a SolrIndexSearcher.QueryCommand from this
 * ResponseBuilder.  TimeAllowed is left unset.
 */
public SolrIndexSearcher.QueryCommand getQueryCommand() {
  SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
  cmd.setQuery(wrap(getQuery()))
          .setFilterList(getFilters())
          .setSort(getSortSpec().getSort())
          .setOffset(getSortSpec().getOffset())
          .setLen(getSortSpec().getCount())
          .setFlags(getFieldFlags())
          .setNeedDocSet(isNeedDocSet())
          .setCursorMark(getCursorMark());
  return cmd;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:ResponseBuilder.java

示例3: setQueryCommand

import org.apache.solr.search.SolrIndexSearcher; //导入方法依赖的package包/类
public Builder setQueryCommand(SolrIndexSearcher.QueryCommand queryCommand) {
  this.queryCommand = queryCommand;
  this.needDocSet = (queryCommand.getFlags() & SolrIndexSearcher.GET_DOCSET) != 0;
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:CommandHandler.java

示例4: prepareGrouping

import org.apache.solr.search.SolrIndexSearcher; //导入方法依赖的package包/类
private void prepareGrouping(ResponseBuilder rb) throws IOException {

    SolrQueryRequest req = rb.req;
    SolrParams params = req.getParams();

    if (null != rb.getCursorMark()) {
      // It's hard to imagine, conceptually, what it would mean to combine
      // grouping with a cursor - so for now we just don't allow the combination at all
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can not use Grouping with " +
                              CursorMarkParams.CURSOR_MARK_PARAM);
    }

    SolrIndexSearcher.QueryCommand cmd = rb.getQueryCommand();
    SolrIndexSearcher searcher = rb.req.getSearcher();
    GroupingSpecification groupingSpec = new GroupingSpecification();
    rb.setGroupingSpec(groupingSpec);

    //TODO: move weighting of sort
    Sort groupSort = searcher.weightSort(cmd.getSort());
    if (groupSort == null) {
      groupSort = Sort.RELEVANCE;
    }

    // groupSort defaults to sort
    String groupSortStr = params.get(GroupParams.GROUP_SORT);
    //TODO: move weighting of sort
    Sort sortWithinGroup = groupSortStr == null ?  groupSort : searcher.weightSort(QueryParsing.parseSortSpec(groupSortStr, req).getSort());
    if (sortWithinGroup == null) {
      sortWithinGroup = Sort.RELEVANCE;
    }

    groupingSpec.setSortWithinGroup(sortWithinGroup);
    groupingSpec.setGroupSort(groupSort);

    String formatStr = params.get(GroupParams.GROUP_FORMAT, Grouping.Format.grouped.name());
    Grouping.Format responseFormat;
    try {
       responseFormat = Grouping.Format.valueOf(formatStr);
    } catch (IllegalArgumentException e) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, String.format(Locale.ROOT, "Illegal %s parameter", GroupParams.GROUP_FORMAT));
    }
    groupingSpec.setResponseFormat(responseFormat);

    groupingSpec.setFields(params.getParams(GroupParams.GROUP_FIELD));
    groupingSpec.setQueries(params.getParams(GroupParams.GROUP_QUERY));
    groupingSpec.setFunctions(params.getParams(GroupParams.GROUP_FUNC));
    groupingSpec.setGroupOffset(params.getInt(GroupParams.GROUP_OFFSET, 0));
    groupingSpec.setGroupLimit(params.getInt(GroupParams.GROUP_LIMIT, 1));
    groupingSpec.setOffset(rb.getSortSpec().getOffset());
    groupingSpec.setLimit(rb.getSortSpec().getCount());
    groupingSpec.setIncludeGroupCount(params.getBool(GroupParams.GROUP_TOTAL_COUNT, false));
    groupingSpec.setMain(params.getBool(GroupParams.GROUP_MAIN, false));
    groupingSpec.setNeedScore((cmd.getFlags() & SolrIndexSearcher.GET_SCORES) != 0);
    groupingSpec.setTruncateGroups(params.getBool(GroupParams.GROUP_TRUNCATE, false));
  }
 
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:QueryComponent.java

示例5: testDocListConversion

import org.apache.solr.search.SolrIndexSearcher; //导入方法依赖的package包/类
@Test
public void testDocListConversion() throws Exception {
  assertU("", adoc("id", "3234", "val_i", "1", 
                   "val_dynamic", "quick red fox"));
  assertU("", adoc("id", "3235", "val_i", "1", 
                   "val_dynamic", "quick green fox"));
  assertU("", adoc("id", "3236", "val_i", "1", 
                   "val_dynamic", "quick brown fox"));
  assertU("", commit());

  RefCounted<SolrIndexSearcher> holder = h.getCore().getSearcher();
  try {
    SolrIndexSearcher srchr = holder.get();
    SolrIndexSearcher.QueryResult qr = new SolrIndexSearcher.QueryResult();
    SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
    cmd.setQuery(new MatchAllDocsQuery());
    cmd.setLen(10);
    qr = srchr.search(qr, cmd);
    
    DocList docs = qr.getDocList();
    assertEquals("wrong docs size", 3, docs.size());
    Set<String> fields = new HashSet<>();
    fields.add("val_dynamic");
    fields.add("dynamic_val");
    fields.add("range_facet_l"); // copied from id
    
    SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
    assertEquals("wrong list Size", docs.size(), list.size());
    for (SolrDocument document : list) {
      
      assertTrue("unexpected field", ! document.containsKey("val_i"));
      assertTrue("unexpected id field", ! document.containsKey("id"));

      assertTrue("original field", document.containsKey("val_dynamic"));
      assertTrue("dyn copy field", document.containsKey("dynamic_val"));
      assertTrue("copy field", document.containsKey("range_facet_l"));
      
      assertNotNull("original field null", document.get("val_dynamic"));
      assertNotNull("dyn copy field null", document.get("dynamic_val"));
      assertNotNull("copy field null", document.get("range_facet_l"));
    }
  } finally {
    if (null != holder) holder.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:SolrPluginUtilsTest.java


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