本文整理汇总了Java中org.apache.solr.common.params.GroupParams类的典型用法代码示例。如果您正苦于以下问题:Java GroupParams类的具体用法?Java GroupParams怎么用?Java GroupParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupParams类属于org.apache.solr.common.params包,在下文中一共展示了GroupParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void init(NamedList args) {
maxOriginalResults = getInt(args, "maxOriginalResults");
String tmp = (String) args.get("allComponentNames");
if (tmp != null) {
componentNames.addAll(Arrays.asList(tmp.split("\\s*,\\s*")));
}
componentNames.add(getComponentName());
componentNames.add(FacetComponent.COMPONENT_NAME);
componentNames.add(HighlightComponent.COMPONENT_NAME);
componentNames.add(StatsComponent.COMPONENT_NAME);
componentNames.add(TermsComponent.COMPONENT_NAME);
componentNames.add(TermVectorComponent.COMPONENT_NAME);
componentNames.add(SpellCheckComponent.COMPONENT_NAME);
componentNames.add(MoreLikeThisComponent.COMPONENT_NAME);
componentNames.add(GroupParams.GROUP);
componentNames.add("queryRelaxer");
componentNames.add("DymReSearcher");
componentNames.add("autoComplete");
commonMisspellingsFileLocation = (String) args.get("commonMisspellingsFile");
commonMisspellingsMap = CommonMisspellings.loadCommonMisspellingsFile(commonMisspellingsFileLocation);
}
示例2: getGroupedFacetQueryCount
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
/**
* Returns a grouped facet count for the facet query
*
* @see FacetParams#FACET_QUERY
*/
public int getGroupedFacetQueryCount(Query facetQuery, DocSet docSet) throws IOException {
// It is okay to retrieve group.field from global because it is never a local param
String groupField = global.get(GroupParams.GROUP_FIELD);
if (groupField == null) {
throw new SolrException (
SolrException.ErrorCode.BAD_REQUEST,
"Specify the group.field as parameter or local parameter"
);
}
TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
Filter mainQueryFilter = docSet.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
Query filteredFacetQuery = new BooleanQuery.Builder()
.add(facetQuery, Occur.MUST)
.add(mainQueryFilter, Occur.FILTER)
.build();
searcher.search(filteredFacetQuery, collector);
return collector.getGroupCount();
}
示例3: getHeatmapCounts
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
final NamedList<Object> resOuter = new SimpleOrderedMap<>();
String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
if (unparsedFields == null || unparsedFields.length == 0) {
return resOuter;
}
if (global.getBool(GroupParams.GROUP_FACET, false)) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Heatmaps can't be used with " + GroupParams.GROUP_FACET);
}
for (String unparsedField : unparsedFields) {
final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs
resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
}
return resOuter;
}
示例4: suggest
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
@Override
protected void suggest(PatientSearch search, FrameTask task) throws FrameException {
SolrQuery query = new SolrQuery("stop_code_name: \"" + ClientUtils.escapeQueryChars(search.getOriginalQueryStr()) + "\"");
query.addFilterQuery("domain:encounter");
query.set(GroupParams.GROUP, true);
query.set(GroupParams.GROUP_FIELD, "stop_code_name");
QueryResponse resp = execSolrQuery(query, task);
GroupResponse group = resp.getGroupResponse();
if (group != null && group.getValues().get(0) != null) {
GroupCommand cmd = group.getValues().get(0);
for (Group grp : cmd.getValues()) {
String val = grp.getGroupValue();
SuggestItem item = new SuggestItem(val, val, "Stop Code");
item.setCategory("Encounters/Visits");
task.addAction(item);
}
}
}
示例5: configureQueryForDocuments
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
private void configureQueryForDocuments(SolrQuery query) {
query.addFilterQuery("domain:document");
query.addSort("reference_date_time", ORDER.desc);
query.addField(Document.SOLR_LOCAL_TITLE_FIELD);
query.addField(Document.SOLR_DOC_DEF_UID_FIELD);
query.addField(Document.SOLR_DOCUMENT_STATUS_FIELD);
query.addField(Document.SOLR_AUTHOR_UID_FIELD);
query.addField(Document.SOLR_SIGNER_UID_FIELD);
query.addField(Document.SOLR_COSIGNER_UID_FIELD);
query.addField((Document.SOLR_ATTENDING_UID_FIELD));
query.addField(Document.SOLR_IS_INTERDISCIPLINARY_FIELD);
query.addField(Document.SOLR_INTERDISCIPLINARY_TYPE_FIELD);
query.addField(SearchService.PHRASE);
query.set(GroupParams.GROUP, true);
query.set(GroupParams.GROUP_FIELD, Document.SOLR_LOCAL_TITLE_FIELD);
query.setHighlight(true);
query.addHighlightField("body").addHighlightField("subject");
query.setHighlightFragsize(45);
query.setHighlightSnippets(5);
}
示例6: list
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
@Override
protected void list(final PatientSearch search, FrameTask task) throws FrameException {
if (!search.searchType("problem")) return;
SolrQuery query = search.initQuery();
query.setQuery("domain:problem");
query.addFilterQuery("-removed:true");
query.addField("smile,comment,icd_code,icd_name,icd_group,problem_status,acuity_name,onset,entered");
query.addFilterQuery("domain:problem");
query.addSort("problem_status", ORDER.asc);
query.addSort(SearchService.DATETIME, ORDER.desc);
query.set(GroupParams.GROUP, true);
query.set(GroupParams.GROUP_FIELD, "icd_group");
query.set(GroupParams.GROUP_LIMIT, 11);
QueryResponse results = execSolrQuery(query, task);
task.addAction(new SolrProblemSearchAction(search, query, results, this.view));
}
示例7: prepareQuery
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
private SolrQuery prepareQuery(PatientSearch search, boolean highlight) {
SolrQuery query = search.initQuery();
query.addFilterQuery("domain:med");
query.addSort("overall_stop", ORDER.desc);
query.addField("qualified_name");
query.addField("va_type");
query.addField("last_filled");
query.addField("last_give");
query.addField(CLASS_FIELD);
query.set(GroupParams.GROUP, true);
query.set(GroupParams.GROUP_FIELD, "kind");
query.add(GroupParams.GROUP_FIELD, "qualified_name");
if (highlight) {
query.setHighlight(true);
query.addHighlightField("administration_comment");
query.addHighlightField("prn_reason");
query.setHighlightFragsize(72);
query.setHighlightSnippets(5);
}
return query;
}
示例8: appendGroupByFields
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
/**
* Append grouping parameters to {@link SolrQuery}
*
* @param solrQuery
* @param fields
*/
protected void appendGroupByFields(SolrQuery solrQuery, List<Field> fields) {
if (CollectionUtils.isEmpty(fields)) {
return;
}
if (fields.size() > 1) {
// there is a bug in solj which prevents multiple grouping
// although available via HTTP call
throw new InvalidDataAccessApiUsageException(
"Cannot group on more than one field with current SolrJ API. Group on single field insead");
}
solrQuery.set(GroupParams.GROUP, true);
solrQuery.setParam(GroupParams.GROUP_MAIN, true);
for (Field field : fields) {
solrQuery.add(GroupParams.GROUP_FIELD, field.getName());
}
}
示例9: search
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
public SearchResult<Conversation> search(Client client, MultiValueMap<String, String> queryParams) throws IOException {
final ModifiableSolrParams solrParams = new ModifiableSolrParams(toListOfStringArrays(queryParams, "text"));
solrParams.add(CommonParams.FL, "id");
solrParams.add(CommonParams.FQ, String.format("%s:\"%s\"", FIELD_OWNER, client.getId().toHexString()));
solrParams.add(CommonParams.FQ, String.format("%s:\"%s\"", FIELD_TYPE, TYPE_MESSAGE));
solrParams.set(GroupParams.GROUP, "true");
solrParams.set(GroupParams.GROUP_FIELD, "_root_");
solrParams.set("group.ngroups", "true");
if (queryParams.containsKey("text")) {
List<String> searchTerms = queryParams.get("text");
String query = SearchUtils.createSearchWordQuery(searchTerms.stream()
.filter(StringUtils::isNotBlank).collect(Collectors.joining(" ")));
if(query != null){
solrParams.set(CommonParams.Q, query);
}
}
log.trace("SolrParams: {}", solrParams);
try (SolrClient solrClient = solrServer.getSolrClient(conversationCore)) {
final QueryResponse queryResponse = solrClient.query(solrParams);
return fromQueryResponse(queryResponse, this::readConversation);
} catch (SolrServerException e) {
throw new IllegalStateException("Cannot query non-initialized core", e);
}
}
示例10: testGroup2
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
@Test
public void testGroup2() {
assertQ(req(CommonParams.QT, "dismax_relaxer", CommonParams.Q,
"+_query_:\"{!type=edismax qf='foo^10.0' v='apple google' mm=100% relax=on}\" +_query_:\"{!type=edismax qf='foo^10.0' v='apple google' mm=0% relax=on}\"",
QueryRelaxerComponent.COMPONENT_NAME, "true",
GroupParams.GROUP, "true",
GroupParams.GROUP_FIELD, "id",
GroupParams.GROUP_LIMIT, "3",
GroupParams.GROUP_TOTAL_COUNT, "true")
,"*[count(//result[@name='response'])=0]"
,"//arr[@name='relaxer_suggestions']/lst[1]//result[@numFound='1']"
);
}
示例11: testGroup
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
@Test
public void testGroup() {
assertQ(req(CommonParams.QT, "dismax_relaxer", CommonParams.Q, "bi marley ",
QueryRelaxerComponent.COMPONENT_NAME, "true", GroupParams.GROUP, "true", GroupParams.GROUP_FIELD, "id")
,"//arr[@name='relaxer_suggestions']/lst[1]/str[@name='relaxedQuery'][.='marley']"
,"//arr[@name='relaxer_suggestions']/lst[1]/lst[@name='relaxer_grouped']/lst[@name='id']/int[@name='matches'][.='7']"
);
}
示例12: getFacetQueryCount
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
public void getFacetQueryCount(ParsedParams parsed, NamedList<Integer> res) throws SyntaxError, IOException {
// TODO: slight optimization would prevent double-parsing of any localParams
// TODO: SOLR-7753
Query qobj = QParser.getParser(parsed.facetValue, req).getQuery();
if (qobj == null) {
res.add(parsed.key, 0);
} else if (parsed.params.getBool(GroupParams.GROUP_FACET, false)) {
res.add(parsed.key, getGroupedFacetQueryCount(qobj, parsed.docs));
} else {
res.add(parsed.key, searcher.numDocs(qobj, parsed.docs));
}
}
示例13: getFacetIntervalCounts
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
/**
* Returns a <code>NamedList</code> with each entry having the "key" of the interval as name and the count of docs
* in that interval as value. All intervals added in the request are included in the returned
* <code>NamedList</code> (included those with 0 count), and it's required that the order of the intervals
* is deterministic and equals in all shards of a distributed request, otherwise the collation of results
* will fail.
*
*/
public NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError {
NamedList<Object> res = new SimpleOrderedMap<Object>();
String[] fields = global.getParams(FacetParams.FACET_INTERVAL);
if (fields == null || fields.length == 0) return res;
for (String field : fields) {
final ParsedParams parsed = parseParams(FacetParams.FACET_INTERVAL, field);
String[] intervalStrs = parsed.required.getFieldParams(parsed.facetValue, FacetParams.FACET_INTERVAL_SET);
SchemaField schemaField = searcher.getCore().getLatestSchema().getField(parsed.facetValue);
if (parsed.params.getBool(GroupParams.GROUP_FACET, false)) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting can't be used with " + GroupParams.GROUP_FACET);
}
if (schemaField.getType().isPointField() && !schemaField.hasDocValues()) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can't use interval faceting on a PointField without docValues");
}
SimpleOrderedMap<Integer> fieldResults = new SimpleOrderedMap<Integer>();
res.add(parsed.key, fieldResults);
IntervalFacets intervalFacets = new IntervalFacets(schemaField, searcher, parsed.docs, intervalStrs, parsed.params);
for (FacetInterval interval : intervalFacets) {
fieldResults.add(interval.getKey(), interval.getCount());
}
}
return res;
}
示例14: getFacetQueryCounts
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
/**
* Returns a list of facet counts for each of the facet queries
* specified in the params
*
* @see FacetParams#FACET_QUERY
*/
public NamedList<Integer> getFacetQueryCounts() throws IOException,SyntaxError {
NamedList<Integer> res = new SimpleOrderedMap<>();
/* Ignore CommonParams.DF - could have init param facet.query assuming
* the schema default with query param DF intented to only affect Q.
* If user doesn't want schema default for facet.query, they should be
* explicit.
*/
// SolrQueryParser qp = searcher.getSchema().getSolrQueryParser(null);
String[] facetQs = params.getParams(FacetParams.FACET_QUERY);
if (null != facetQs && 0 != facetQs.length) {
for (String q : facetQs) {
parseParams(FacetParams.FACET_QUERY, q);
// TODO: slight optimization would prevent double-parsing of any localParams
Query qobj = QParser.getParser(q, null, req).getQuery();
if (qobj == null) {
res.add(key, 0);
} else if (params.getBool(GroupParams.GROUP_FACET, false)) {
res.add(key, getGroupedFacetQueryCount(qobj));
} else {
res.add(key, searcher.numDocs(qobj, docs));
}
}
}
return res;
}
示例15: getGroupedFacetQueryCount
import org.apache.solr.common.params.GroupParams; //导入依赖的package包/类
/**
* Returns a grouped facet count for the facet query
*
* @see FacetParams#FACET_QUERY
*/
public int getGroupedFacetQueryCount(Query facetQuery) throws IOException {
String groupField = params.get(GroupParams.GROUP_FIELD);
if (groupField == null) {
throw new SolrException (
SolrException.ErrorCode.BAD_REQUEST,
"Specify the group.field as parameter or local parameter"
);
}
TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
searcher.search(facetQuery, mainQueryFilter, collector);
return collector.getGroupCount();
}