mirror of https://github.com/apache/lucene.git
SOLR-9193: Add scoreNodes Streaming Expression
This commit is contained in:
parent
551bdc6f53
commit
e1f51a20d7
|
@ -118,7 +118,7 @@ public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, P
|
|||
.withFunctionName("shortestPath", ShortestPathStream.class)
|
||||
.withFunctionName("gatherNodes", GatherNodesStream.class)
|
||||
.withFunctionName("sort", SortStream.class)
|
||||
|
||||
.withFunctionName("scoreNodes", ScoreNodesStream.class)
|
||||
|
||||
// metrics
|
||||
.withFunctionName("min", MinMetric.class)
|
||||
|
|
|
@ -126,6 +126,7 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
|
|||
.withFunctionName("shortestPath", ShortestPathStream.class)
|
||||
.withFunctionName("gatherNodes", GatherNodesStream.class)
|
||||
.withFunctionName("select", SelectStream.class)
|
||||
.withFunctionName("scoreNodes", ScoreNodesStream.class)
|
||||
|
||||
// metrics
|
||||
.withFunctionName("min", MinMetric.class)
|
||||
|
|
|
@ -140,6 +140,8 @@ public abstract class SearchComponent implements SolrInfoMBean, NamedListInitial
|
|||
map.put(DebugComponent.COMPONENT_NAME, DebugComponent.class);
|
||||
map.put(RealTimeGetComponent.COMPONENT_NAME, RealTimeGetComponent.class);
|
||||
map.put(ExpandComponent.COMPONENT_NAME, ExpandComponent.class);
|
||||
map.put(TermsComponent.COMPONENT_NAME, TermsComponent.class);
|
||||
|
||||
standard_components = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,8 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
|
|||
names.add( StatsComponent.COMPONENT_NAME );
|
||||
names.add( DebugComponent.COMPONENT_NAME );
|
||||
names.add( ExpandComponent.COMPONENT_NAME);
|
||||
names.add( TermsComponent.COMPONENT_NAME);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,14 @@ public class TermsComponent extends SearchComponent {
|
|||
|
||||
if (fields == null || fields.length==0) return;
|
||||
|
||||
boolean termStats = params.getBool(TermsParams.TERMS_STATS, false);
|
||||
|
||||
if(termStats) {
|
||||
NamedList<Number> stats = new SimpleOrderedMap();
|
||||
rb.rsp.add("stats", stats);
|
||||
collectStats(rb.req.getSearcher(), stats);
|
||||
}
|
||||
|
||||
String termList = params.get(TermsParams.TERMS_LIST);
|
||||
if(termList != null) {
|
||||
fetchTerms(rb.req.getSearcher(), fields, termList, termsResult);
|
||||
|
@ -291,6 +299,13 @@ public class TermsComponent extends SearchComponent {
|
|||
@SuppressWarnings("unchecked")
|
||||
NamedList<NamedList<Number>> terms = (NamedList<NamedList<Number>>) srsp.getSolrResponse().getResponse().get("terms");
|
||||
th.parse(terms);
|
||||
|
||||
|
||||
NamedList<Number> stats = (NamedList<Number>)srsp.getSolrResponse().getResponse().get("stats");
|
||||
if(stats != null) {
|
||||
th.numDocs += stats.get("numDocs").longValue();
|
||||
th.stats = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,6 +320,11 @@ public class TermsComponent extends SearchComponent {
|
|||
NamedList terms = ti.buildResponse();
|
||||
|
||||
rb.rsp.add("terms", terms);
|
||||
if(ti.stats) {
|
||||
NamedList<Number> stats = new SimpleOrderedMap();
|
||||
stats.add("numDocs", Long.valueOf(ti.numDocs));
|
||||
rb.rsp.add("stats", stats);
|
||||
}
|
||||
rb._termsHelper = null;
|
||||
}
|
||||
|
||||
|
@ -331,6 +351,8 @@ public class TermsComponent extends SearchComponent {
|
|||
// map to store returned terms
|
||||
private HashMap<String, HashMap<String, TermsResponse.Term>> fieldmap;
|
||||
private SolrParams params;
|
||||
public long numDocs = 0;
|
||||
public boolean stats;
|
||||
|
||||
public TermsHelper() {
|
||||
fieldmap = new HashMap<>(5);
|
||||
|
@ -547,6 +569,11 @@ public class TermsComponent extends SearchComponent {
|
|||
}
|
||||
}
|
||||
|
||||
private void collectStats(SolrIndexSearcher searcher, NamedList<Number> stats) {
|
||||
int numDocs = searcher.getTopReaderContext().reader().numDocs();
|
||||
stats.add("numDocs", Long.valueOf(numDocs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "A Component for working with Term Enumerators";
|
||||
|
|
|
@ -104,6 +104,12 @@
|
|||
"wt": "json",
|
||||
"distrib": false
|
||||
}
|
||||
},
|
||||
"/terms": {
|
||||
"class": "solr.SearchHandler",
|
||||
"components": [
|
||||
"terms"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -114,7 +114,9 @@ public class MinimalSchemaTest extends SolrTestCaseJ4 {
|
|||
handler.startsWith("/export") ||
|
||||
handler.startsWith("/graph") ||
|
||||
handler.startsWith("/sql") ||
|
||||
handler.startsWith("/stream")
|
||||
handler.startsWith("/stream") ||
|
||||
handler.startsWith("/terms")
|
||||
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
|
|||
++ihCount; assertEquals(pathToClassMap.get("/admin/threads"), "solr.ThreadDumpHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get("/config"), "solr.SolrConfigHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get("/export"), "solr.SearchHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get("/terms"), "solr.SearchHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get("/get"), "solr.RealTimeGetHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get(ReplicationHandler.PATH), "solr.ReplicationHandler");
|
||||
++ihCount; assertEquals(pathToClassMap.get("/schema"), "solr.SchemaHandler");
|
||||
|
|
|
@ -51,6 +51,8 @@ public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase
|
|||
query("qt", "/terms", "shards.qt", "/terms", "terms", "true", "terms.fl", "b_t", "terms.sort", "index");
|
||||
query("qt", "/terms", "shards.qt", "/terms", "terms", "true", "terms.fl", "b_t", "terms.list", "snake, zebra, ant, bad");
|
||||
query("qt", "/terms", "shards.qt", "/terms", "terms", "true", "terms.fl", "foo_i", "terms.list", "2, 3, 1");
|
||||
query("qt", "/terms", "shards.qt", "/terms", "terms", "true", "terms.fl", "foo_i", "terms.stats", "true","terms.list", "2, 3, 1");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
|
|||
,"//lst[@name='standardfilt']/int[4][@name='spider'][.='1']"
|
||||
);
|
||||
|
||||
|
||||
//Test with numeric terms
|
||||
assertQ(req("indent","true", "qt","/terms", "terms","true",
|
||||
"terms.fl","foo_i",
|
||||
|
@ -190,6 +191,17 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStats() throws Exception {
|
||||
//Terms list always returns in index order
|
||||
assertQ(req("indent", "true", "qt", "/terms", "terms", "true",
|
||||
"terms.fl", "standardfilt","terms.stats", "true",
|
||||
"terms.list", "spider, snake, shark, ddddd, bad")
|
||||
, "//lst[@name='stats']/int[1][@name='numDocs'][.='23']"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortIndex() throws Exception {
|
||||
assertQ(req("indent","true", "qt","/terms", "terms","true",
|
||||
|
|
|
@ -0,0 +1,245 @@
|
|||
package org.apache.solr.client.solrj.io.stream;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.io.SolrClientCache;
|
||||
import org.apache.solr.client.solrj.io.Tuple;
|
||||
import org.apache.solr.client.solrj.io.comp.StreamComparator;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.Explanation;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.Expressible;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.TermsParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
/**
|
||||
* Iterates over a gatherNodes() expression and scores the node Tuples based based on tf-idf.
|
||||
*
|
||||
* Expression Syntax:
|
||||
*
|
||||
* Default function call uses the "count(*)" value for node freq.
|
||||
*
|
||||
* You can use a different value for node freq by providing the nodeFreq param
|
||||
* scoreNodes(gatherNodes(...), nodeFreq="min(weight)")
|
||||
*
|
||||
**/
|
||||
|
||||
public class ScoreNodesStream extends TupleStream implements Expressible
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
protected String zkHost;
|
||||
private TupleStream stream;
|
||||
private transient SolrClientCache clientCache;
|
||||
private Map<String, Tuple> nodes = new HashMap();
|
||||
private Iterator<Tuple> tuples;
|
||||
private String termFreq;
|
||||
|
||||
public ScoreNodesStream(TupleStream tupleStream, String nodeFreqField) throws IOException {
|
||||
init(tupleStream, nodeFreqField);
|
||||
}
|
||||
|
||||
public ScoreNodesStream(StreamExpression expression, StreamFactory factory) throws IOException {
|
||||
// grab all parameters out
|
||||
List<StreamExpression> streamExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, TupleStream.class);
|
||||
StreamExpressionNamedParameter nodeFreqParam = factory.getNamedOperand(expression, "termFreq");
|
||||
|
||||
String docFreqField = "count(*)";
|
||||
if(nodeFreqParam != null) {
|
||||
docFreqField = nodeFreqParam.getParameter().toString();
|
||||
}
|
||||
|
||||
if(1 != streamExpressions.size()){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting a single stream but found %d",expression, streamExpressions.size()));
|
||||
}
|
||||
|
||||
zkHost = factory.getDefaultZkHost();
|
||||
|
||||
if(null == zkHost){
|
||||
throw new IOException("zkHost not found");
|
||||
}
|
||||
|
||||
TupleStream stream = factory.constructStream(streamExpressions.get(0));
|
||||
|
||||
init(stream, docFreqField);
|
||||
}
|
||||
|
||||
private void init(TupleStream tupleStream, String termFreq) throws IOException{
|
||||
this.stream = tupleStream;
|
||||
this.termFreq = termFreq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamExpression toExpression(StreamFactory factory) throws IOException{
|
||||
return toExpression(factory, true);
|
||||
}
|
||||
|
||||
private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
|
||||
// function name
|
||||
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
|
||||
|
||||
// nodeFreqField
|
||||
expression.addParameter(new StreamExpressionNamedParameter("termFreq", termFreq));
|
||||
|
||||
if(includeStreams){
|
||||
// stream
|
||||
if(stream instanceof Expressible){
|
||||
expression.addParameter(((Expressible)stream).toExpression(factory));
|
||||
}
|
||||
else{
|
||||
throw new IOException("This ScoreNodesStream contains a non-expressible TupleStream - it cannot be converted to an expression");
|
||||
}
|
||||
}
|
||||
else{
|
||||
expression.addParameter("<stream>");
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation toExplanation(StreamFactory factory) throws IOException {
|
||||
|
||||
return new StreamExplanation(getStreamNodeId().toString())
|
||||
.withChildren(new Explanation[]{
|
||||
stream.toExplanation(factory)
|
||||
})
|
||||
.withFunctionName(factory.getFunctionName(this.getClass()))
|
||||
.withImplementingClass(this.getClass().getName())
|
||||
.withExpressionType(ExpressionType.STREAM_DECORATOR)
|
||||
.withExpression(toExpression(factory, false).toString());
|
||||
}
|
||||
|
||||
public void setStreamContext(StreamContext context) {
|
||||
this.clientCache = context.getSolrClientCache();
|
||||
this.stream.setStreamContext(context);
|
||||
}
|
||||
|
||||
public List<TupleStream> children() {
|
||||
List<TupleStream> l = new ArrayList();
|
||||
l.add(stream);
|
||||
return l;
|
||||
}
|
||||
|
||||
public void open() throws IOException {
|
||||
stream.open();
|
||||
Tuple node = null;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String field = null;
|
||||
String collection = null;
|
||||
while(true) {
|
||||
node = stream.read();
|
||||
if(node.EOF) {
|
||||
break;
|
||||
}
|
||||
|
||||
String nodeId = node.getString("node");
|
||||
nodes.put(nodeId, node);
|
||||
if(builder.length() > 0) {
|
||||
builder.append(",");
|
||||
field = node.getString("field");
|
||||
collection = node.getString("collection");
|
||||
}
|
||||
builder.append(nodeId);
|
||||
}
|
||||
|
||||
CloudSolrClient client = clientCache.getCloudSolrClient(zkHost);
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.add(CommonParams.QT, "/terms");
|
||||
params.add(TermsParams.TERMS, "true");
|
||||
params.add(TermsParams.TERMS_FIELD, field);
|
||||
params.add(TermsParams.TERMS_STATS, "true");
|
||||
params.add(TermsParams.TERMS_LIST, builder.toString());
|
||||
QueryRequest request = new QueryRequest(params);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
//Get the response from the terms component
|
||||
NamedList response = client.request(request, collection);
|
||||
NamedList<Number> stats = (NamedList<Number>)response.get("stats");
|
||||
long numDocs = stats.get("numDocs").longValue();
|
||||
NamedList<NamedList<Number>> fields = (NamedList<NamedList<Number>>)response.get("terms");
|
||||
|
||||
int size = fields.size();
|
||||
for(int i=0; i<size; i++) {
|
||||
String fieldName = fields.getName(i);
|
||||
NamedList<Number> terms = fields.get(fieldName);
|
||||
int tsize = terms.size();
|
||||
for(int t=0; t<tsize; t++) {
|
||||
String term = terms.getName(t);
|
||||
Number docFreq = terms.get(term);
|
||||
Tuple tuple = nodes.get(term);
|
||||
Number termFreqValue = (Number)tuple.get(termFreq);
|
||||
float score = termFreqValue.floatValue() * (float) (Math.log((numDocs + 1) / (docFreq.doubleValue() + 1)) + 1.0);
|
||||
tuple.put("nodeScore", score);
|
||||
tuple.put("docFreq", docFreq);
|
||||
tuple.put("numDocs", numDocs);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
tuples = nodes.values().iterator();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
stream.close();
|
||||
}
|
||||
|
||||
public StreamComparator getComparator(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tuple read() throws IOException {
|
||||
if(tuples.hasNext()) {
|
||||
return tuples.next();
|
||||
} else {
|
||||
Map map = new HashMap();
|
||||
map.put("EOF", true);
|
||||
return new Tuple(map);
|
||||
}
|
||||
}
|
||||
|
||||
public StreamComparator getStreamSort(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -44,6 +44,12 @@ public interface TermsParams {
|
|||
*/
|
||||
public static final String TERMS_LIST = TERMS_PREFIX + "list";
|
||||
|
||||
/**
|
||||
* Optional. The list of terms to be retrieved.
|
||||
*
|
||||
*/
|
||||
public static final String TERMS_STATS = TERMS_PREFIX + "stats";
|
||||
|
||||
/**
|
||||
* Optional. The lower bound term to start at. The TermEnum will start at the next term after this term in the dictionary.
|
||||
*
|
||||
|
|
|
@ -40,6 +40,8 @@ import org.apache.solr.client.solrj.io.comp.ComparatorOrder;
|
|||
import org.apache.solr.client.solrj.io.comp.FieldComparator;
|
||||
import org.apache.solr.client.solrj.io.stream.CloudSolrStream;
|
||||
import org.apache.solr.client.solrj.io.stream.HashJoinStream;
|
||||
import org.apache.solr.client.solrj.io.stream.ScoreNodesStream;
|
||||
import org.apache.solr.client.solrj.io.stream.SortStream;
|
||||
import org.apache.solr.client.solrj.io.stream.StreamContext;
|
||||
import org.apache.solr.client.solrj.io.stream.TupleStream;
|
||||
import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
|
||||
|
@ -384,6 +386,94 @@ public class GraphExpressionTest extends SolrCloudTestCase {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testScoreNodesStream() throws Exception {
|
||||
|
||||
|
||||
new UpdateRequest()
|
||||
.add(id, "0", "basket_s", "basket1", "product_s", "product1", "price_f", "20")
|
||||
.add(id, "1", "basket_s", "basket1", "product_s", "product3", "price_f", "30")
|
||||
.add(id, "2", "basket_s", "basket1", "product_s", "product5", "price_f", "1")
|
||||
.add(id, "3", "basket_s", "basket2", "product_s", "product1", "price_f", "2")
|
||||
.add(id, "4", "basket_s", "basket2", "product_s", "product6", "price_f", "5")
|
||||
.add(id, "5", "basket_s", "basket2", "product_s", "product7", "price_f", "10")
|
||||
.add(id, "6", "basket_s", "basket3", "product_s", "product4", "price_f", "20")
|
||||
.add(id, "7", "basket_s", "basket3", "product_s", "product3", "price_f", "10")
|
||||
.add(id, "8", "basket_s", "basket3", "product_s", "product1", "price_f", "10")
|
||||
.add(id, "9", "basket_s", "basket4", "product_s", "product4", "price_f", "40")
|
||||
.add(id, "10", "basket_s", "basket4", "product_s", "product3", "price_f", "10")
|
||||
.add(id, "11", "basket_s", "basket4", "product_s", "product1", "price_f", "10")
|
||||
.add(id, "12", "basket_s", "basket5", "product_s", "product1", "price_f", "10")
|
||||
.add(id, "13", "basket_s", "basket6", "product_s", "product1", "price_f", "10")
|
||||
.add(id, "14", "basket_s", "basket7", "product_s", "product1", "price_f", "10")
|
||||
.add(id, "15", "basket_s", "basket4", "product_s", "product1", "price_f", "10")
|
||||
.commit(cluster.getSolrClient(), COLLECTION);
|
||||
|
||||
List<Tuple> tuples = null;
|
||||
Set<String> paths = null;
|
||||
TupleStream stream = null;
|
||||
StreamContext context = new StreamContext();
|
||||
SolrClientCache cache = new SolrClientCache();
|
||||
context.setSolrClientCache(cache);
|
||||
|
||||
StreamFactory factory = new StreamFactory()
|
||||
.withCollectionZkHost("collection1", cluster.getZkServer().getZkAddress())
|
||||
.withDefaultZkHost(cluster.getZkServer().getZkAddress())
|
||||
.withFunctionName("gatherNodes", GatherNodesStream.class)
|
||||
.withFunctionName("scoreNodes", ScoreNodesStream.class)
|
||||
.withFunctionName("search", CloudSolrStream.class)
|
||||
.withFunctionName("sort", SortStream.class)
|
||||
.withFunctionName("count", CountMetric.class)
|
||||
.withFunctionName("avg", MeanMetric.class)
|
||||
.withFunctionName("sum", SumMetric.class)
|
||||
.withFunctionName("min", MinMetric.class)
|
||||
.withFunctionName("max", MaxMetric.class);
|
||||
|
||||
String expr = "gatherNodes(collection1, " +
|
||||
"walk=\"product3->product_s\"," +
|
||||
"gather=\"basket_s\")";
|
||||
|
||||
|
||||
String expr2 = "sort(by=\"nodeScore desc\", " +
|
||||
"scoreNodes(gatherNodes(collection1, " +
|
||||
expr+","+
|
||||
"walk=\"node->basket_s\"," +
|
||||
"gather=\"product_s\", " +
|
||||
"count(*), " +
|
||||
"avg(price_f), " +
|
||||
"sum(price_f), " +
|
||||
"min(price_f), " +
|
||||
"max(price_f))))";
|
||||
|
||||
stream = factory.constructStream(expr2);
|
||||
|
||||
context = new StreamContext();
|
||||
context.setSolrClientCache(cache);
|
||||
|
||||
stream.setStreamContext(context);
|
||||
|
||||
tuples = getTuples(stream);
|
||||
|
||||
Tuple tuple0 = tuples.get(0);
|
||||
assert(tuple0.getString("node").equals("product4"));
|
||||
assert(tuple0.getLong("docFreq") == 2);
|
||||
assert(tuple0.getLong("count(*)") == 2);
|
||||
|
||||
Tuple tuple1 = tuples.get(1);
|
||||
assert(tuple1.getString("node").equals("product1"));
|
||||
assert(tuple1.getLong("docFreq") == 8);
|
||||
assert(tuple1.getLong("count(*)") == 3);
|
||||
|
||||
Tuple tuple2 = tuples.get(2);
|
||||
assert(tuple2.getString("node").equals("product5"));
|
||||
assert(tuple2.getLong("docFreq") == 1);
|
||||
assert(tuple2.getLong("count(*)") == 1);
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGatherNodesFriendsStream() throws Exception {
|
||||
|
||||
|
@ -707,6 +797,11 @@ public class GraphExpressionTest extends SolrCloudTestCase {
|
|||
client.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String readString(InputStreamReader reader) throws Exception{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int c = 0;
|
||||
|
|
Loading…
Reference in New Issue