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


Java FunctionQParser类代码示例

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


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

示例1: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
  ValueSource source = fp.parseValueSource();
  final float nvl = fp.parseFloat();

  return new SimpleFloatFunction(source) {
    @Override
  protected String name() {
      return "nvl";
    }

    @Override
    protected float func(int doc, FunctionValues vals) {
      float v = vals.floatVal(doc);
      if (v == nvlFloatValue) {
        return nvl;
      } else {
        return v;
      }
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:NvlValueSourceParser.java

示例2: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    // hitcount() takes no arguments.  If we wanted to pass a query
    // we could call fp.parseNestedQuery()
    HashSet<String> fields = new HashSet<String>(); 
    while (fp.hasMoreArguments()) {
        fields.add(fp.parseArg());
    }
    Query q = fp.subQuery(fp.getParams().get("q"), "lucene").getQuery();
    HashSet<Term> terms = new HashSet<Term>(); 
    try {
        q.extractTerms(terms);
    } catch (UnsupportedOperationException e) {
        return new DoubleConstValueSource (1);
    }
    ArrayList<ValueSource> termcounts = new ArrayList<ValueSource>();
    for (Term t : terms) {
        if (fields.isEmpty() || fields.contains (t.field())) {
            termcounts.add (new TermFreqValueSource(t.field(), t.text(), t.field(), t.bytes()));
        }
    }
    return new SumFloatFunction(termcounts.toArray(new ValueSource[termcounts.size()]));
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:24,代码来源:HitCount.java

示例3: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {

   // get cache key
   String cacheName = checkNotNull(fp).parseArg();
   String cacheKey = checkNotNull(fp).parseArg();

   // get cache from searcher
   @SuppressWarnings("unchecked")
   SolrCache<String, FloatCachingValueSource> cache = fp.getReq().getSearcher().getCache(cacheName);
   checkNotNull(cache, "Could not get boostCache from Searcher.");

   // get cached functions from cache
   FloatCachingValueSource valueSource = cache.get(cacheKey);

   return checkNotNull(valueSource, "Could not load pre-cached values for cache key " + cacheKey);
}
 
开发者ID:shopping24,项目名称:solr-bmax-queryparser,代码行数:18,代码来源:CachedBoostValueSourceParser.java

示例4: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    String field=fp.parseArg();                          // eg. cl_hi
    String featureString = fp.parseArg();
    // System.out.println(featureString);
    byte[] hist= Base64.decodeBase64(featureString);     // eg. FQY5DhMYDg0ODg0PEBEPDg4ODg8QEgsgEBAQEBAgEBAQEBA=
    double maxDistance = Double.MAX_VALUE;
    if (fp.hasMoreArguments()) {                           // if there is a third argument, it's the max value to return if there is none. Note the query cache is not updated upon parameter change.
        maxDistance = Double.parseDouble(fp.parseArg());
    }
    return new LireValueSource(field, hist, maxDistance);
}
 
开发者ID:dermotte,项目名称:liresolr,代码行数:13,代码来源:LireValueSourceParser.java

示例5: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
  String fieldName = fp.parseId();
  SchemaField field = fp.getReq().getSchema().getField(fieldName);
  FieldType type = field.getType();
  if (!(type instanceof MultiPointDocValuesField))
    throw new SyntaxError("This function only supports fields of type "+
        MultiPointDocValuesField.class.getName()+", not "+type.getClass().getName());
  MultiPointDocValuesField mpdvFieldType = (MultiPointDocValuesField) type;

  double[] parsedLatLong = null;
  try {
    parsedLatLong = ParseUtils.parseLatitudeLongitude(fp.parseArg());
  } catch (InvalidShapeException e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
  }

  double y = parsedLatLong[0];
  double x = parsedLatLong[1];

  SpatialContext ctx = mpdvFieldType.getCtx();
  Point point = ctx.makePoint(x, y);

  String score = fp.getLocalParams().get("score", "distance");
  ValueSource valueSource = new MultiPointDistanceValueSource(fieldName, point, ctx);

  if ("distance".equals(score)) {
    return valueSource;
  }
  else if ("recipDistance".equals(score)) {
    int shift = fp.getLocalParams().getInt("shift", 100);
    int maxScore = fp.getLocalParams().getInt("maxScore", 10);
    return new ReciprocalFloatFunction(valueSource, maxScore, shift, shift);
  }
  else {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "'score' local-param must be one of 'distance', or 'recipDistance'");
  }
}
 
开发者ID:randomstatistic,项目名称:SOLR-5170,代码行数:39,代码来源:MultiPointDistanceValueSourceParser.java

示例6: parsePoint

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
  String ptStr = fp.getParam(SpatialParams.POINT);
  if (ptStr == null) return null;
  Point point = SpatialUtils.parsePointSolrException(ptStr, SpatialContext.GEO);
  //assume Lat Lon order
  return new VectorValueSource(
      Arrays.<ValueSource>asList(new DoubleConstValueSource(point.getY()), new DoubleConstValueSource(point.getX())));
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:GeoDistValueSourceParser.java

示例7: parseSfield

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private MultiValueSource parseSfield(FunctionQParser fp) throws SyntaxError {
  String sfield = fp.getParam(SpatialParams.FIELD);
  if (sfield == null) return null;
  SchemaField sf = fp.getReq().getSchema().getField(sfield);
  FieldType type = sf.getType();
  if (type instanceof AbstractSpatialFieldType) {
    AbstractSpatialFieldType asft = (AbstractSpatialFieldType) type;
    return new SpatialStrategyMultiValueSource(asft.getStrategy(sfield));
  }
  ValueSource vs = type.getValueSource(sf, fp);
  if (vs instanceof MultiValueSource) {
    return (MultiValueSource)vs;
  }
  throw new SyntaxError("Spatial field must implement MultiValueSource or extend AbstractSpatialFieldType:" + sf);
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:GeoDistValueSourceParser.java

示例8: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
  String key = fp.parseArg();
  double val = fp.parseDouble();
  
  AtomicInteger counter = new AtomicInteger();
  if (null != counters.putIfAbsent(key, counter)) {
    throw new IllegalArgumentException("Key has already been used: " + key);
  } 
  return new CountDocsValueSource(counter, val);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:CountUsageValueSourceParser.java

示例9: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    ParamInfo paramInfo = parseTerm(fp);
    if(paramInfo == null){
        return new DoubleConstValueSource(-1.0d);
    }

    if(paramInfo.terms.size() == 0){
        return new DoubleConstValueSource(0.0d);
    }

    return new TermIntersectsValueSource(paramInfo.field, paramInfo.analyzer, paramInfo.terms, paramInfo.similarity);
}
 
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:14,代码来源:TermIntersectsValueSourceParser.java

示例10: parseTerm

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private static ParamInfo parseTerm(FunctionQParser fp) throws SyntaxError {
    ParamInfo paramInfo = new ParamInfo();

    paramInfo.field = fp.parseArg();
    String textVal = fp.parseArg();
    if(textVal == null || textVal.trim().length() == 0){
        return paramInfo;
    }

    if(fp.hasMoreArguments()){
        String similarity = fp.parseArg().toLowerCase().trim();
        if( !similarity.equals(SimilarityType.DOC_LEN) &&
            !similarity.equals(SimilarityType.PARAM_LEN) &&
            !similarity.equals(SimilarityType.DICE) &&
            !similarity.equals(SimilarityType.JACCARD)){

            log.error(String.format("Invalid similarity class: %s. Defaulting to %s", similarity, SimilarityType.DOC_LEN));
            similarity = SimilarityType.DOC_LEN;
        }
        paramInfo.similarity = similarity;
    }

    // need to do analysis on the term
    Analyzer analyzer = fp.getReq().getSchema().getIndexAnalyzer();
    paramInfo.analyzer = analyzer;
    try {
        List<String> terms = TermExtractionHelper.getTermsFromString(analyzer, paramInfo.field, textVal);
        paramInfo.terms = new HashSet<String>(terms);
    } catch (IOException e) {
        SolrException.log(log, "Exception during debug", e);
        return null;
    }
    return paramInfo;
}
 
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:35,代码来源:TermIntersectsValueSourceParser.java

示例11: parsePoint

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
    String pt = fp.getParam(SpatialParams.POINT);
    if (pt == null) return null;
    double[] point = null;
    try {
        point = ParseUtils.parseLatitudeLongitude(pt);
    } catch (InvalidShapeException e) {
        throw new SyntaxError("Bad spatial pt:" + pt);
    }
    return new VectorValueSource(Arrays.<ValueSource>asList(new DoubleConstValueSource(point[0]), new DoubleConstValueSource(point[1])));
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:12,代码来源:DistanceParser.java

示例12: parseSfield

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private MultiValueSource parseSfield(FunctionQParser fp) throws SyntaxError {
    String sfield = fp.getParam(SpatialParams.FIELD);
    if (sfield == null) return null;
    SchemaField sf = fp.getReq().getSchema().getField(sfield);
    FieldType type = sf.getType();
    if (type instanceof AbstractSpatialFieldType) {
        AbstractSpatialFieldType asft = (AbstractSpatialFieldType) type;
        return new SpatialStrategyMultiValueSource(asft.getStrategy(sfield));
    }
    ValueSource vs = type.getValueSource(sf, fp);
    if (vs instanceof MultiValueSource) {
        return (MultiValueSource)vs;
    }
    throw new SyntaxError("Spatial field must implement MultiValueSource or extend AbstractSpatialFieldType:" + sf);
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:16,代码来源:DistanceParser.java

示例13: parsePoint

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private static MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
  String pt = fp.getParam(SpatialParams.POINT);
  if (pt == null) return null;
  double[] point = null;
  try {
    point = ParseUtils.parseLatitudeLongitude(pt);
  } catch (InvalidShapeException e) {
    throw new SyntaxError("Bad spatial pt:" + pt);
  }
  return new VectorValueSource(Arrays.<ValueSource>asList(new DoubleConstValueSource(point[0]),new DoubleConstValueSource(point[1])));
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:12,代码来源:HaversineConstFunction.java

示例14: parseSfield

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
private static MultiValueSource parseSfield(FunctionQParser fp) throws SyntaxError {
  String sfield = fp.getParam(SpatialParams.FIELD);
  if (sfield == null) return null;
  SchemaField sf = fp.getReq().getSchema().getField(sfield);
  ValueSource vs = sf.getType().getValueSource(sf, fp);
  if (!(vs instanceof MultiValueSource)) {
    throw new SyntaxError("Spatial field must implement MultiValueSource:" + sf);
  }
  return (MultiValueSource)vs;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:HaversineConstFunction.java

示例15: parse

import org.apache.solr.search.FunctionQParser; //导入依赖的package包/类
/**
 * Provide a ValueSource for external process results, which are obtained from the
 * request context (having been placed there by XJoinSearchComponent).
 */
@Override
public ValueSource parse(FunctionQParser fqp) throws SyntaxError {
  String componentName = this.componentName != null ? this.componentName : fqp.parseArg();
  String attribute = this.attribute != null ? this.attribute : fqp.parseArg();
  
  XJoinSearchComponent xJoin = (XJoinSearchComponent)fqp.getReq().getCore().getSearchComponent(componentName);
  String joinField = xJoin.getJoinField();
  XJoinResults<?> results = (XJoinResults<?>)fqp.getReq().getContext().get(xJoin.getResultsTag());
  if (results == null) {
    throw new RuntimeException("No xjoin results in request context");
  }
  return new XJoinValueSource(joinField, results, attribute);
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:18,代码来源:XJoinValueSourceParser.java


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