Java Code Examples for org.apache.solr.search.FunctionQParser#parseArg()

The following examples show how to use org.apache.solr.search.FunctionQParser#parseArg() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChildFieldValueSourceParser.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
  
  final String sortFieldName = fp.parseArg();
  final Query query;
  if (fp.hasMoreArguments()){
    query = fp.parseNestedQuery();
  } else {
    query = fp.subQuery(fp.getParam(CommonParams.Q), null).getQuery();
  }
  
  BitSetProducer parentFilter;
  BitSetProducer childFilter;
  SchemaField sf;
  try {
    AllParentsAware bjQ;
    if (!(query instanceof AllParentsAware)) {
      throw new SyntaxError("expect a reference to block join query "+
            AllParentsAware.class.getSimpleName()+" in "+fp.getString());
    }
    bjQ = (AllParentsAware) query;
    
    parentFilter = BlockJoinParentQParser.getCachedBitSetProducer(fp.getReq(), bjQ.getParentQuery());
    childFilter = BlockJoinParentQParser.getCachedBitSetProducer(fp.getReq(), bjQ.getChildQuery());

    if (sortFieldName==null || sortFieldName.equals("")) {
      throw new SyntaxError ("field is omitted in "+fp.getString());
    }
    
    sf = fp.getReq().getSchema().getFieldOrNull(sortFieldName);
    if (null == sf) {
      throw new SyntaxError
        (NAME+" sort param field \""+ sortFieldName+"\" can't be found in schema");
    }
  } catch (SyntaxError e) {
    log.error("can't parse {}", fp.getString(), e);
    throw e;
  }
  return new BlockJoinSortFieldValueSource(childFilter, parentFilter, sf);
}
 
Example 2
Source File: CountUsageValueSourceParser.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: LireValueSourceParser.java    From liresolr with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: XJoinValueSourceParser.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: XJoinValueSourceParser.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: XJoinValueSourceParser.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}