使用
/export
终点:
导出结果集
。
它支持使用相同的
fl
参数作为常规搜索(尽管只搜索
:
当你使用SolrJ时,它可能会表现得非常相似。
在SolrJ你必须使用
CloudSolrStream
而不是正确地传输结果(与搜索时的常规行为相比)
:
)。
import org.apache.solr.client.solrj.io.;
import java.util.;
public class StreamingClient {
public static void main(String args[]) throws IOException {
String zkHost = args[0];
String collection = args[1];
Map props = new HashMap();
props.put("q", "*:*");
props.put("qt", "/export");
props.put("sort", "fieldA asc");
props.put("fl", "fieldA,fieldB,fieldC");
CloudSolrStream cstream = new CloudSolrStream(zkHost,
collection,
props);
try {
cstream.open();
while(true) {
Tuple tuple = cstream.read();
if(tuple.EOF) {
break;
}
String fieldA = tuple.getString("fieldA");
String fieldB = tuple.getString("fieldB");
String fieldC = tuple.getString("fieldC");
System.out.println(fieldA + ", " + fieldB + ", " + fieldC);
}
} finally {
cstream.close();
}
}
}
</code>