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


Java FacetParams类代码示例

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


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

示例1: testFacetAndHighlight

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
@Test
public void testFacetAndHighlight() {
  assertQ(req(CommonParams.QT, "standardGoodSuggestion", 
      CommonParams.Q, "foo:bobo AND foo:marley",
      SpellingParams.SPELLCHECK_COLLATE, "true", 
      SpellingParams.SPELLCHECK_BUILD, "true", 
      SpellingParams.SPELLCHECK_COUNT, "10", 
      SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true",
      FacetParams.FACET, "true", 
      FacetParams.FACET_FIELD, "foo", 
      FacetParams.FACET_FIELD, "id", 
      FacetParams.FACET_FIELD, "bar", 
      FacetParams.FACET_QUERY, "id:[0 TO 20]", 
      FacetParams.FACET_QUERY, "id:[1 TO 100]", 
      HighlightParams.HIGHLIGHT, "true", 
      HighlightParams.FIELDS, "foo",
      DymReSearcher.COMPONENT_NAME, "true",
      SpellCheckComponent.COMPONENT_NAME, "true")
      ,"//result[@name='spellchecked_response'][@numFound='7']"
      ,"//result[@name='response'][@numFound='0']"
      ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='7']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='7']"
      ,"//lst[@name='spellchecked_highlighting']/lst[@name='2']/arr[@name='foo']/str[1]");
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:26,代码来源:TestDymReSearcher.java

示例2: testFacetAndHighlightWithCommonMisspellings

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
@Test
public void testFacetAndHighlightWithCommonMisspellings() {
  assertQ(req(CommonParams.QT, "standardResWithCommonMisspellings", 
      CommonParams.Q, "foo:bobo AND foo:marley",
      SpellingParams.SPELLCHECK_COLLATE, "true", 
      SpellingParams.SPELLCHECK_BUILD, "true", 
      SpellingParams.SPELLCHECK_COUNT, "10", 
      SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true",
      FacetParams.FACET, "true", 
      FacetParams.FACET_FIELD, "foo", 
      FacetParams.FACET_FIELD, "id",
      FacetParams.FACET_FIELD, "bar", 
      FacetParams.FACET_QUERY, "id:[0 TO 20]", 
      FacetParams.FACET_QUERY, "id:[1 TO 100]",
      HighlightParams.HIGHLIGHT, "true", 
      HighlightParams.FIELDS, "foo",
      DymReSearcher.COMPONENT_NAME, "true",
      SpellCheckComponent.COMPONENT_NAME, "true")
      ,"//result[@name='spellchecked_response'][@numFound='3']"
      ,"//result[@name='response'][@numFound='0']"
      ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bono AND foo:marley']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='3']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='3']"
      ,"//lst[@name='spellchecked_highlighting']/lst[@name='9']/arr[@name='foo']/str[1]"
      );
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:27,代码来源:TestDymReSearcher.java

示例3: getFacetQueryCounts

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
/**
 * Returns a list of facet counts for each of the facet queries
 * specified in the params
 *
 * @see FacetParams#FACET_QUERY
 */
public NamedList<Integer> getFacetQueryCounts() throws IOException,SyntaxError {

  NamedList<Integer> res = new SimpleOrderedMap<>();

  /* Ignore CommonParams.DF - could have init param facet.query assuming
   * the schema default with query param DF intented to only affect Q.
   * If user doesn't want schema default for facet.query, they should be
   * explicit.
   */
  // SolrQueryParser qp = searcher.getSchema().getSolrQueryParser(null);

  String[] facetQs = global.getParams(FacetParams.FACET_QUERY);

  if (null != facetQs && 0 != facetQs.length) {
    for (String q : facetQs) {
      final ParsedParams parsed = parseParams(FacetParams.FACET_QUERY, q);
      getFacetQueryCount(parsed, res);
    }
  }

  return res;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:29,代码来源:SimpleFacets.java

示例4: newBytesRefFilter

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
protected Predicate<BytesRef> newBytesRefFilter(String field, SolrParams params) {
  final String contains = params.getFieldParam(field, FacetParams.FACET_CONTAINS);

  final Predicate<BytesRef> containsFilter;
  if (contains != null) {
    final boolean containsIgnoreCase = params.getFieldBool(field, FacetParams.FACET_CONTAINS_IGNORE_CASE, false);
    containsFilter = new SubstringBytesRefFilter(contains, containsIgnoreCase);
  } else {
    containsFilter = null;
  }

  final Predicate<BytesRef> excludeFilter = newExcludeBytesRefFilter(field, params);

  if (containsFilter == null && excludeFilter == null) {
    return null;
  }

  if (containsFilter != null && excludeFilter == null) {
    return containsFilter;
  } else if (containsFilter == null && excludeFilter != null) {
    return excludeFilter;
  }

  return containsFilter.and(excludeFilter);
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:26,代码来源:SimpleFacets.java

示例5: selectFacetMethod

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
/**
  * @param existsRequested facet.exists=true is passed for the given field
  * */
static FacetMethod selectFacetMethod(String fieldName, 
                                     SchemaField field, FacetMethod method, Integer mincount,
                                     boolean existsRequested) {
  if (existsRequested) {
    checkMincountOnExists(fieldName, mincount);
    if (method == null) {
      method = FacetMethod.ENUM;
    }
  }
  final FacetMethod facetMethod = selectFacetMethod(field, method, mincount);
  
  if (existsRequested && facetMethod!=FacetMethod.ENUM) {
    throw new SolrException (ErrorCode.BAD_REQUEST, 
        FacetParams.FACET_EXISTS + "=true is requested, but "+
        FacetParams.FACET_METHOD+"="+FacetParams.FACET_METHOD_enum+ " can't be used with "+fieldName
    );
  }
  return facetMethod;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:23,代码来源:SimpleFacets.java

示例6: getHeatmapCounts

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
  if (unparsedFields == null || unparsedFields.length == 0) {
    return resOuter;
  }
  if (global.getBool(GroupParams.GROUP_FACET, false)) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
        "Heatmaps can't be used with " + GroupParams.GROUP_FACET);
  }
  for (String unparsedField : unparsedFields) {
    final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs

    resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
  }
  return resOuter;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:18,代码来源:SimpleFacets.java

示例7: initContext

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
/**
 * Initializes FacetContext using request parameters and saves it in the request
 * context which can be retrieved via {@link #getFacetContext(SolrQueryRequest)}
 *
 * @param rb the ResponseBuilder object from which the request parameters are read
 *           and to which the FacetContext object is saved.
 */
public static void initContext(ResponseBuilder rb)  {
  // Parse facet queries and ranges and put them in the request
  // context so that they can be hung under pivots if needed without re-parsing
  List<RangeFacetRequest> facetRanges = null;
  List<FacetBase> facetQueries = null;

  String[] ranges = rb.req.getParams().getParams(FacetParams.FACET_RANGE);
  if (ranges != null) {
    facetRanges = new ArrayList<>(ranges.length);
    for (String range : ranges) {
      RangeFacetRequest rangeFacetRequest = new RangeFacetRequest(rb, range);
      facetRanges.add(rangeFacetRequest);
    }
  }

  String[] queries = rb.req.getParams().getParams(FacetParams.FACET_QUERY);
  if (queries != null)  {
    facetQueries = new ArrayList<>();
    for (String query : queries) {
      facetQueries.add(new FacetBase(rb, FacetParams.FACET_QUERY, query));
    }
  }

  rb.req.getContext().put(FACET_CONTEXT_KEY, new FacetContext(facetRanges, facetQueries));
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:33,代码来源:FacetComponent.java

示例8: removeQueryFacetsUnderLimits

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
private void removeQueryFacetsUnderLimits(ResponseBuilder rb) {
  if (rb.stage != ResponseBuilder.STAGE_EXECUTE_QUERY) {
    return;
  }
  FacetInfo fi = rb._facetInfo;
  Map<String, QueryFacet> query_facets = fi.queryFacets;
  if (query_facets == null) {
    return;
  }
  LinkedHashMap<String, QueryFacet> newQueryFacets = new LinkedHashMap<>();

  // The
  int minCount = rb.req.getParams().getInt(FacetParams.FACET_MINCOUNT, 0);
  boolean replace = false;
  for (Map.Entry<String, QueryFacet> ent : query_facets.entrySet()) {
    if (ent.getValue().count >= minCount) {
      newQueryFacets.put(ent.getKey(), ent.getValue());
    } else {
      log.trace("Removing facetQuery/key: " + ent.getKey() + "/" + ent.getValue().toString() + " mincount=" + minCount);
      replace = true;
    }
  }
  if (replace) {
    fi.queryFacets = newQueryFacets;
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:27,代码来源:FacetComponent.java

示例9: removeRangeFacetsUnderLimits

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
private void removeRangeFacetsUnderLimits(ResponseBuilder rb) {
  if (rb.stage != ResponseBuilder.STAGE_EXECUTE_QUERY) {
    return;
  }

  FacetInfo fi = rb._facetInfo;
  for (Map.Entry<String, RangeFacetRequest.DistribRangeFacet> entry : fi.rangeFacets.entrySet()) {
    final String field = entry.getKey();
    final RangeFacetRequest.DistribRangeFacet rangeFacet = entry.getValue();

    int minCount = rb.req.getParams().getFieldInt(field, FacetParams.FACET_MINCOUNT, 0);
    if (minCount == 0) {
      continue;
    }

    rangeFacet.removeRangeFacetsUnderLimits(minCount);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:19,代码来源:FacetComponent.java

示例10: removeFieldFacetsUnderLimits

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
private void removeFieldFacetsUnderLimits(ResponseBuilder rb) {
  if (rb.stage != ResponseBuilder.STAGE_DONE) {
    return;
  }

  FacetInfo fi = rb._facetInfo;
  if (fi.facets == null) {
    return;
  }
  // Do field facets
  for (Entry<String, DistribFieldFacet> ent : fi.facets.entrySet()) {
    String field = ent.getKey();
    int minCount = rb.req.getParams().getFieldInt(field, FacetParams.FACET_MINCOUNT, 0);
    if (minCount == 0) { // return them all
      continue;
    }
    ent.getValue().respectMinCount(minCount);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:20,代码来源:FacetComponent.java

示例11: setFacet

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
/** enable/disable faceting.  
 * 
 * @param b flag to indicate faceting should be enabled. <br /> if b==false, removes all other faceting parameters
 * @return Current reference (<i>this</i>)
 */
public SolrQuery setFacet(boolean b) {
  if (b) {
    this.set(FacetParams.FACET, true);
  } else {
    this.remove(FacetParams.FACET);
    this.remove(FacetParams.FACET_MINCOUNT);
    this.remove(FacetParams.FACET_FIELD);
    this.remove(FacetParams.FACET_LIMIT);
    this.remove(FacetParams.FACET_MISSING);
    this.remove(FacetParams.FACET_OFFSET);
    this.remove(FacetParams.FACET_PREFIX);
    this.remove(FacetParams.FACET_QUERY);
    this.remove(FacetParams.FACET_SORT);
    this.remove(FacetParams.FACET_ZEROS);
    this.remove(FacetParams.FACET_PREFIX); // does not include the individual fields...
    this.remove(FacetParams.FACET_INTERVAL); // does not remove interval parameters
  }
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:SolrQuery.java

示例12: testFacetNumericRange

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
public void testFacetNumericRange() {
  SolrQuery q = new SolrQuery("dog");
  q.addNumericRangeFacet("field", 1, 10, 1);
  assertEquals("true", q.get(FacetParams.FACET));
  assertEquals("field", q.get(FacetParams.FACET_RANGE));
  assertEquals("1", q.get("f.field." + FacetParams.FACET_RANGE_START));
  assertEquals("10", q.get("f.field." + FacetParams.FACET_RANGE_END));
  assertEquals("1", q.get("f.field." + FacetParams.FACET_RANGE_GAP));

  q = new SolrQuery("dog");
  q.addNumericRangeFacet("field", 1.0d, 10.0d, 1.0d);
  assertEquals("true", q.get(FacetParams.FACET));
  assertEquals("field", q.get(FacetParams.FACET_RANGE));
  assertEquals("1.0", q.get("f.field." + FacetParams.FACET_RANGE_START));
  assertEquals("10.0", q.get("f.field." + FacetParams.FACET_RANGE_END));
  assertEquals("1.0", q.get("f.field." + FacetParams.FACET_RANGE_GAP));

  q = new SolrQuery("dog");
  q.addNumericRangeFacet("field", 1.0f, 10.0f, 1.0f);
  assertEquals("true", q.get(FacetParams.FACET));
  assertEquals("field", q.get(FacetParams.FACET_RANGE));
  assertEquals("1.0", q.get("f.field." + FacetParams.FACET_RANGE_START));
  assertEquals("10.0", q.get("f.field." + FacetParams.FACET_RANGE_END));
  assertEquals("1.0", q.get("f.field." + FacetParams.FACET_RANGE_GAP));
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrQueryTest.java

示例13: getFacetDateCounts

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
/**
 * Returns a list of value constraints and the associated facet counts 
 * for each facet date field, range, and interval specified in the
 * SolrParams
 *
 * @see FacetParams#FACET_DATE
 * @deprecated Use getFacetRangeCounts which is more generalized
 */
@Deprecated
public NamedList<Object> getFacetDateCounts()
  throws IOException, SyntaxError {

  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  final String[] fields = params.getParams(FacetParams.FACET_DATE);

  if (null == fields || 0 == fields.length) return resOuter;

  for (String f : fields) {
    getFacetDateCounts(f, resOuter);
  }

  return resOuter;
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SimpleFacets.java

示例14: modifyRequest

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
public void modifyRequest(ResponseBuilder rb, SearchComponent who,ShardRequest sreq) {

    if (!rb.doFacets) return;
    
    if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
      sreq.purpose |= ShardRequest.PURPOSE_GET_FACETS;
      
      FacetInfo fi = rb._facetInfo;
      if (fi == null) {
        rb._facetInfo = fi = new FacetInfo();
        fi.parse(rb.req.getParams(), rb);
      }
      
      modifyRequestForFieldFacets(rb, sreq, fi);
      
      modifyRequestForPivotFacets(rb, sreq, fi.pivotFacets);
      
      sreq.params.remove(FacetParams.FACET_MINCOUNT);
      sreq.params.remove(FacetParams.FACET_OFFSET);
      
    } else {
      // turn off faceting on other requests
      sreq.params.set(FacetParams.FACET, "false");
      // we could optionally remove faceting params
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:FacetComponent.java

示例15: FacetBase

import org.apache.solr.common.params.FacetParams; //导入依赖的package包/类
public FacetBase(ResponseBuilder rb, String facetType, String facetStr) {
  this.facetType = facetType;
  this.facetStr = facetStr;
  try {
    this.localParams = QueryParsing.getLocalParams(facetStr,
                                                   rb.req.getParams());
  } catch (SyntaxError e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
  }
  this.facetOn = facetStr;
  this.key = facetStr;
  
  if (localParams != null) {
    // remove local params unless it's a query
    if (!facetType.equals(FacetParams.FACET_QUERY)) {
      facetOn = localParams.get(CommonParams.VALUE);
      key = facetOn;
    }
    
    key = localParams.get(CommonParams.OUTPUT_KEY, key);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:FacetComponent.java


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