use of org.apache.lucene.queries.function.ValueSource in project lucene-solr by apache.
the class BoostQParserPlugin method createParser.
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
return new QParser(qstr, localParams, params, req) {
QParser baseParser;
ValueSource vs;
String b;
@Override
public Query parse() throws SyntaxError {
b = localParams.get(BOOSTFUNC);
baseParser = subQuery(localParams.get(QueryParsing.V), null);
Query q = baseParser.getQuery();
if (b == null)
return q;
Query bq = subQuery(b, FunctionQParserPlugin.NAME).getQuery();
if (bq instanceof FunctionQuery) {
vs = ((FunctionQuery) bq).getValueSource();
} else {
vs = new QueryValueSource(bq, 0.0f);
}
return new BoostedQuery(q, vs);
}
@Override
public String[] getDefaultHighlightFields() {
return baseParser.getDefaultHighlightFields();
}
@Override
public Query getHighlightQuery() throws SyntaxError {
return baseParser.getHighlightQuery();
}
@Override
public void addDebugInfo(NamedList<Object> debugInfo) {
// encapsulate base debug info in a sub-list?
baseParser.addDebugInfo(debugInfo);
debugInfo.add("boost_str", b);
debugInfo.add("boost_parsed", vs);
}
};
}
use of org.apache.lucene.queries.function.ValueSource in project lucene-solr by apache.
the class MultiBoolFunction method getValues.
@Override
public BoolDocValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
final FunctionValues[] vals = new FunctionValues[sources.size()];
int i = 0;
for (ValueSource source : sources) {
vals[i++] = source.getValues(context, readerContext);
}
return new BoolDocValues(this) {
@Override
public boolean boolVal(int doc) throws IOException {
return func(doc, vals);
}
@Override
public String toString(int doc) throws IOException {
StringBuilder sb = new StringBuilder(name());
sb.append('(');
boolean first = true;
for (FunctionValues dv : vals) {
if (first) {
first = false;
} else {
sb.append(',');
}
sb.append(dv.toString(doc));
}
return sb.toString();
}
};
}
use of org.apache.lucene.queries.function.ValueSource in project lucene-solr by apache.
the class MultiFloatFunction method description.
@Override
public String description() {
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(');
boolean firstTime = true;
for (ValueSource source : sources) {
if (firstTime) {
firstTime = false;
} else {
sb.append(',');
}
sb.append(source);
}
sb.append(')');
return sb.toString();
}
use of org.apache.lucene.queries.function.ValueSource in project lucene-solr by apache.
the class MultiFunction method valsArr.
public static FunctionValues[] valsArr(List<ValueSource> sources, Map fcontext, LeafReaderContext readerContext) throws IOException {
final FunctionValues[] valsArr = new FunctionValues[sources.size()];
int i = 0;
for (ValueSource source : sources) {
valsArr[i++] = source.getValues(fcontext, readerContext);
}
return valsArr;
}
use of org.apache.lucene.queries.function.ValueSource in project lucene-solr by apache.
the class MultiFunction method description.
public static String description(String name, List<ValueSource> sources) {
StringBuilder sb = new StringBuilder();
sb.append(name).append('(');
boolean firstTime = true;
for (ValueSource source : sources) {
if (firstTime) {
firstTime = false;
} else {
sb.append(',');
}
sb.append(source);
}
sb.append(')');
return sb.toString();
}
Aggregations