public ValueSource parse(FunctionQParser fqp) throws SyntaxError{ ValueSource value1 = fqp.parseValueSource(); ValueSource value2 = fqp.parseValueSource(); String delimiter = null; if (fqp.hasMoreArguments()){ delimiter = fqp.parseArg(); } return new ConcatenateFunction(value1, value2, delimiter); } }
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { return new FunctionQParser(qstr, localParams, params, req); } }
/** * Parse a list of ValueSource. Must be the final set of arguments * to a ValueSource. * * @return List<ValueSource> * @throws ParseException */ public List<ValueSource> parseValueSourceList() throws ParseException { List<ValueSource> sources = new ArrayList<ValueSource>(3); for (;;) { sources.add(parseValueSource(false)); if (! consumeArgumentDelimiter()) break; } return sources; }
public ValueSource parse(FunctionQParser fp) throws ParseException { ValueSource source = fp.parseValueSource(); float min = fp.parseFloat(); float max = fp.parseFloat(); float target = fp.parseFloat(); Float def = fp.hasMoreArguments() ? fp.parseFloat() : null; return new RangeMapFloatFunction(source,min,max,target,def); }
public ValueSource parse(FunctionQParser fp) throws ParseException { ValueSource source = fp.parseValueSource(); float m = fp.parseFloat(); float a = fp.parseFloat(); float b = fp.parseFloat(); return new ReciprocalFloatFunction(source,m,a,b); }
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; }
@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); } }
public ValueSource parse(FunctionQParser fp) throws ParseException { Query q = fp.parseNestedQuery(); float defVal = 0.0f; if (fp.hasMoreArguments()) { defVal = fp.parseFloat(); } return new QueryValueSource(q, defVal); }
public ValueSource parse(FunctionQParser fp) throws ParseException { ValueSource source = fp.parseValueSource(); return new SimpleFloatFunction(source) { protected String name() { return "sqrt"; } protected float func(int doc, DocValues vals) { return (float)Math.sqrt(vals.floatVal(doc)); } }; } public void init(NamedList args) {
/** * Consume an argument delimiter (a comma) from the token stream. * Only consumes if more arguments should exist (no ending parens or end of string). * * @return whether a delimiter was consumed * @throws ParseException */ protected boolean consumeArgumentDelimiter() throws ParseException { /* if a list of args is ending, don't expect the comma */ if (hasMoreArguments()) { sp.expect(","); return true; } return false; }
String qstr = getParam(param); qstr = qstr==null ? "" : qstr; nestedQuery = subQuery(qstr, null).getQuery(); int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams()); sub = subQuery(qs.substring(start, end), null); } else { sub = subQuery(qs, null); consumeArgumentDelimiter();
public ValueSource parse(FunctionQParser fp) throws ParseException { Query q = fp.parseNestedQuery(); ValueSource vs = fp.parseValueSource(); BoostedQuery bq = new BoostedQuery(q, vs); return new QueryValueSource(bq, 0.0f); }
public Query parse() throws ParseException { sp = new QueryParsing.StrParser(getString()); ValueSource vs = parseValueSource(); /*** boost promoted to top-level query type to avoid this hack // HACK - if this is a boosted query wrapped in a value-source, return // that boosted query instead of a FunctionQuery if (vs instanceof QueryValueSource) { Query q = ((QueryValueSource)vs).getQuery(); if (q instanceof BoostedQuery) return q; } ***/ return new FunctionQuery(vs); }
sp.pos++; String param = sp.getId(); val = getParam(param); break; case '\'': consumeArgumentDelimiter(); return val;
/** * TODO: Doc * * @throws ParseException */ public String parseId() throws ParseException { String value = sp.getId(); consumeArgumentDelimiter(); return value; }
private static FieldInfo parseTerm(FunctionQParser fp) throws SyntaxError { FieldInfo fieldInfo = new FieldInfo(); fieldInfo.indexedField = fieldInfo.field = fp.parseArg(); String textVal = fp.parseArg(); if(textVal == null || textVal.trim().length() == 0){ return fieldInfo; if(fp.hasMoreArguments()){ fieldInfo.useDocLength = fp.parseArg().toLowerCase().equals("true"); Analyzer analyzer = fp.getReq().getSchema().getIndexAnalyzer(); TokenStream ts = analyzer.tokenStream(fieldInfo.field, new StringReader(textVal)); try {
public ValueSource parse(FunctionQParser fp) throws ParseException { ValueSource source = fp.parseValueSource(); float slope = fp.parseFloat(); float intercept = fp.parseFloat(); return new LinearFloatFunction(source,slope,intercept); }