use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.
the class CdcrReplicatorManager method getCheckpoint.
private long getCheckpoint(CdcrReplicatorState state) throws IOException, SolrServerException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CommonParams.ACTION, CdcrParams.CdcrAction.COLLECTIONCHECKPOINT.toString());
SolrRequest request = new QueryRequest(params);
request.setPath(path);
NamedList response = state.getClient().request(request);
return (Long) response.get(CdcrParams.CHECKPOINT);
}
use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.
the class CdcrReplicatorManager method sendCdcrCommand.
private NamedList sendCdcrCommand(SolrClient client, CdcrParams.CdcrAction action, String... params) throws SolrServerException, IOException {
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.set(CommonParams.QT, "/cdcr");
solrParams.set(CommonParams.ACTION, action.toString());
for (int i = 0; i < params.length - 1; i += 2) {
solrParams.set(params[i], params[i + 1]);
}
SolrRequest request = new QueryRequest(solrParams);
return client.request(request);
}
use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.
the class SolrTable method handleSelectDistinctMapReduce.
private TupleStream handleSelectDistinctMapReduce(final String zkHost, final String collection, final Properties properties, final List<Map.Entry<String, Class>> fields, final String query, final List<Pair<String, String>> orders, final Bucket[] buckets, final String limit) throws IOException {
int numWorkers = Integer.parseInt(properties.getProperty("numWorkers", "1"));
String fl = getFields(fields);
String sort = null;
StreamEqualitor ecomp = null;
StreamComparator comp = null;
if (orders != null && orders.size() > 0) {
StreamComparator[] adjustedSorts = adjustSorts(orders, buckets);
// Because of the way adjustSorts works we know that each FieldComparator has a single
// field name. For this reason we can just look at the leftFieldName
FieldEqualitor[] fieldEqualitors = new FieldEqualitor[adjustedSorts.length];
StringBuilder buf = new StringBuilder();
for (int i = 0; i < adjustedSorts.length; i++) {
FieldComparator fieldComparator = (FieldComparator) adjustedSorts[i];
fieldEqualitors[i] = new FieldEqualitor(fieldComparator.getLeftFieldName());
if (i > 0) {
buf.append(",");
}
buf.append(fieldComparator.getLeftFieldName()).append(" ").append(fieldComparator.getOrder().toString());
}
sort = buf.toString();
if (adjustedSorts.length == 1) {
ecomp = fieldEqualitors[0];
comp = adjustedSorts[0];
} else {
ecomp = new MultipleFieldEqualitor(fieldEqualitors);
comp = new MultipleFieldComparator(adjustedSorts);
}
} else {
StringBuilder sortBuf = new StringBuilder();
FieldEqualitor[] equalitors = new FieldEqualitor[buckets.length];
StreamComparator[] streamComparators = new StreamComparator[buckets.length];
for (int i = 0; i < buckets.length; i++) {
equalitors[i] = new FieldEqualitor(buckets[i].toString());
streamComparators[i] = new FieldComparator(buckets[i].toString(), ComparatorOrder.ASCENDING);
if (i > 0) {
sortBuf.append(',');
}
sortBuf.append(buckets[i].toString()).append(" asc");
}
sort = sortBuf.toString();
if (equalitors.length == 1) {
ecomp = equalitors[0];
comp = streamComparators[0];
} else {
ecomp = new MultipleFieldEqualitor(equalitors);
comp = new MultipleFieldComparator(streamComparators);
}
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CommonParams.FL, fl);
params.set(CommonParams.Q, query);
params.set(CommonParams.WT, CommonParams.JAVABIN);
//Always use the /export handler for Distinct Queries because it requires exporting full result sets.
params.set(CommonParams.QT, "/export");
if (numWorkers > 1) {
params.set("partitionKeys", getPartitionKeys(buckets));
}
params.set(SORT, sort);
TupleStream tupleStream = null;
CloudSolrStream cstream = new CloudSolrStream(zkHost, collection, params);
tupleStream = new UniqueStream(cstream, ecomp);
if (numWorkers > 1) {
// Do the unique in parallel
// Maintain the sort of the Tuples coming from the workers.
ParallelStream parallelStream = new ParallelStream(zkHost, collection, tupleStream, numWorkers, comp);
StreamFactory factory = new StreamFactory().withFunctionName("search", CloudSolrStream.class).withFunctionName("parallel", ParallelStream.class).withFunctionName("unique", UniqueStream.class);
parallelStream.setStreamFactory(factory);
tupleStream = parallelStream;
}
if (limit != null) {
tupleStream = new LimitStream(tupleStream, Integer.parseInt(limit));
}
return tupleStream;
}
use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.
the class PostingsSolrHighlighter method getHighlighter.
@Override
protected UnifiedHighlighter getHighlighter(SolrQueryRequest req) {
// Adjust the highlight parameters to match what the old PostingsHighlighter had.
ModifiableSolrParams invariants = new ModifiableSolrParams();
invariants.set(HighlightParams.OFFSET_SOURCE, "POSTINGS");
invariants.set(HighlightParams.FIELD_MATCH, true);
invariants.set(HighlightParams.USE_PHRASE_HIGHLIGHTER, false);
invariants.set(HighlightParams.FRAGSIZE, -1);
ModifiableSolrParams defaults = new ModifiableSolrParams();
defaults.set(HighlightParams.DEFAULT_SUMMARY, true);
defaults.set(HighlightParams.TAG_ELLIPSIS, "... ");
SolrParams newParams = SolrParams.wrapDefaults(// this takes precedence
invariants, SolrParams.wrapDefaults(// then this (original)
req.getParams(), // finally our defaults
defaults));
try (LocalSolrQueryRequest fakeReq = new LocalSolrQueryRequest(req.getCore(), newParams)) {
return super.getHighlighter(fakeReq);
}
}
use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.
the class SolrTable method handleStats.
private TupleStream handleStats(String zk, String collection, String query, List<Pair<String, String>> metricPairs, List<Map.Entry<String, Class>> fields) {
Map<String, Class> fmap = new HashMap();
for (Map.Entry<String, Class> entry : fields) {
fmap.put(entry.getKey(), entry.getValue());
}
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.add(CommonParams.Q, query);
Metric[] metrics = buildMetrics(metricPairs, false).toArray(new Metric[0]);
for (Metric metric : metrics) {
Class c = fmap.get(metric.getIdentifier());
if (Long.class.equals(c)) {
metric.outputLong = true;
}
}
return new StatsStream(zk, collection, solrParams, metrics);
}
Aggregations