本文整理汇总了Java中org.apache.solr.common.params.SolrParams.getParams方法的典型用法代码示例。如果您正苦于以下问题:Java SolrParams.getParams方法的具体用法?Java SolrParams.getParams怎么用?Java SolrParams.getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.params.SolrParams
的用法示例。
在下文中一共展示了SolrParams.getParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SolrContentHandler
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public SolrContentHandler(Metadata metadata, SolrParams params,
IndexSchema schema, Collection<String> dateFormats) {
this.document = new SolrInputDocument();
this.metadata = metadata;
this.params = params;
this.schema = schema;
this.dateFormats = dateFormats;
this.lowerNames = params.getBool(LOWERNAMES, false);
this.captureAttribs = params.getBool(CAPTURE_ATTRIBUTES, false);
this.literalsOverride = params.getBool(LITERALS_OVERRIDE, true);
this.unknownFieldPrefix = params.get(UNKNOWN_FIELD_PREFIX, "");
this.defaultField = params.get(DEFAULT_FIELD, "");
String[] captureFields = params.getParams(CAPTURE_ELEMENTS);
if (captureFields != null && captureFields.length > 0) {
fieldBuilders = new HashMap<>();
for (int i = 0; i < captureFields.length; i++) {
fieldBuilders.put(captureFields[i], new StringBuilder());
}
} else {
fieldBuilders = Collections.emptyMap();
}
bldrStack.add(catchAllBuilder);
}
示例2: getCustomFieldsMap
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Prepares a map of Solr field names (keys) to the corresponding Carrot2
* custom field names.
*/
private Map<String, String> getCustomFieldsMap(SolrParams solrParams) {
Map<String, String> customFields = Maps.newHashMap();
String [] customFieldsSpec = solrParams.getParams(CarrotParams.CUSTOM_FIELD_NAME);
if (customFieldsSpec != null) {
customFields = Maps.newHashMap();
for (String customFieldSpec : customFieldsSpec) {
String [] split = customFieldSpec.split(":");
if (split.length == 2 && StringUtils.isNotBlank(split[0]) && StringUtils.isNotBlank(split[1])) {
customFields.put(split[0], split[1]);
} else {
log.warn("Unsupported format for " + CarrotParams.CUSTOM_FIELD_NAME
+ ": '" + customFieldSpec + "'. Skipping this field definition.");
}
}
}
return customFields;
}
示例3: addBoostFunctions
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
String[] boostFuncs = solrParams.getParams(DisMaxParams.BF);
if (null != boostFuncs && 0 != boostFuncs.length) {
for (String boostFunc : boostFuncs) {
if (null == boostFunc || "".equals(boostFunc)) continue;
Map<String, Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc);
for (String f : ff.keySet()) {
Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery();
Float b = ff.get(f);
if (null != b) {
fq.setBoost(b);
}
query.add(fq, BooleanClause.Occur.SHOULD);
}
}
}
}
示例4: getFieldsParameter
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
protected String[] getFieldsParameter(SolrParams params) {
final String paramName = getPrefix() + "." + JointProbabilityParams.FIELDS;
String[] fields = params.getParams(paramName);
if(fields == null || fields.length == 0){
fields = this.fields;
}
if(fields == null || fields.length == 0){
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
String.format("%s is a required parameter", paramName)
);
}
for(int i = 0; i<fields.length; i++){
String fld = fields[i];
// if a single field, make a pair
if(fld.split(",").length == 0){
throw new SolrException (SolrException.ErrorCode.BAD_REQUEST,"No fields specified");
}
}
return fields;
}
示例5: parse
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
void parse(SolrParams params, ResponseBuilder rb) {
queryFacets = new LinkedHashMap<>();
facets = new LinkedHashMap<>();
String[] facetQs = params.getParams(FacetParams.FACET_QUERY);
if (facetQs != null) {
for (String query : facetQs) {
QueryFacet queryFacet = new QueryFacet(rb, query);
queryFacets.put(queryFacet.getKey(), queryFacet);
}
}
String[] facetFs = params.getParams(FacetParams.FACET_FIELD);
if (facetFs != null) {
for (String field : facetFs) {
final DistribFieldFacet ff;
if (params.getFieldBool(field, FacetParams.FACET_EXISTS, false)) {
// cap facet count by 1 with this method
ff = new DistribFacetExistsField(rb, field);
} else {
ff = new DistribFieldFacet(rb, field);
}
facets.put(ff.getKey(), ff);
}
}
// Develop Pivot Facet Information
String[] facetPFs = params.getParams(FacetParams.FACET_PIVOT);
if (facetPFs != null) {
for (String fieldGroup : facetPFs) {
PivotFacet pf = new PivotFacet(rb, fieldGroup);
pivotFacets.add(pf.getKey(), pf);
}
}
heatmapFacets = SpatialHeatmapFacets.distribParse(params, rb);
}
示例6: toMultiMap
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/** Create a Map<String,String[]> from {@link org.apache.solr.common.params.SolrParams}*/
public static Map<String, String[]> toMultiMap(SolrParams solrParams) {
HashMap<String,String[]> multiValuedMap = new HashMap<String, String[]>();
Iterator<String> params = solrParams.getParameterNamesIterator();
while (params.hasNext()) {
String param = params.next();
String[] values = solrParams.getParams(param);
if (values != null) {
multiValuedMap.put(param, values);
}
}
return multiValuedMap;
}
示例7: toQueryString
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public static String toQueryString( SolrParams params, boolean xml ) {
StringBuilder sb = new StringBuilder(128);
try {
String amp = xml ? "&" : "&";
boolean first=true;
Iterator<String> names = params.getParameterNamesIterator();
while( names.hasNext() ) {
String key = names.next();
String[] valarr = params.getParams( key );
if( valarr == null ) {
sb.append( first?"?":amp );
sb.append(key);
first=false;
}
else {
for (String val : valarr) {
sb.append( first? "?":amp );
sb.append(key);
if( val != null ) {
sb.append('=');
sb.append( URLEncoder.encode( val, "UTF-8" ) );
}
first=false;
}
}
}
}
catch (IOException e) {throw new RuntimeException(e);} // can't happen
return sb.toString();
}
示例8: getParamsMap
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private Map<String, Object> getParamsMap(SolrParams params) {
Iterator<String> names = params.getParameterNamesIterator();
Map<String, Object> result = new HashMap<>();
while (names.hasNext()) {
String s = names.next();
String[] val = params.getParams(s);
if (val == null || val.length < 1)
continue;
if (val.length == 1)
result.put(s, val[0]);
else
result.put(s, Arrays.asList(val));
}
return result;
}
示例9: passParam
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private void passParam(SolrParams params, ModifiableSolrParams fparams, String param) {
String[] values = params.getParams(param);
if (values != null) {
for (String value : values) {
fparams.add(param, value);
}
}
}
示例10: initHidden
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public static Set<String> initHidden(SolrParams invariants) {
Set<String> hiddenRet = new HashSet<>();
// Build a list of hidden files
if (invariants != null) {
String[] hidden = invariants.getParams(HIDDEN);
if (hidden != null) {
for (String s : hidden) {
hiddenRet.add(s.toUpperCase(Locale.ROOT));
}
}
}
return hiddenRet;
}
示例11: parse
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
void parse(SolrParams params, ResponseBuilder rb) {
queryFacets = new LinkedHashMap<>();
facets = new LinkedHashMap<>();
String[] facetQs = params.getParams(FacetParams.FACET_QUERY);
if (facetQs != null) {
for (String query : facetQs) {
QueryFacet queryFacet = new QueryFacet(rb, query);
queryFacets.put(queryFacet.getKey(), queryFacet);
}
}
String[] facetFs = params.getParams(FacetParams.FACET_FIELD);
if (facetFs != null) {
for (String field : facetFs) {
DistribFieldFacet ff = new DistribFieldFacet(rb, field);
facets.put(ff.getKey(), ff);
}
}
// Develop Pivot Facet Information
String[] facetPFs = params.getParams(FacetParams.FACET_PIVOT);
if (facetPFs != null) {
for (String fieldGroup : facetPFs) {
PivotFacet pf = new PivotFacet(rb, fieldGroup);
pivotFacets.add(pf.getKey(), pf);
}
}
}
示例12: handleRequestBody
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Expands aliases into queries for thematic collections.
*
* Operates by taking apart the passed request, scanning it for thematic-collection keywords,
* and replacing those it finds with the appropriate expanded query.
*
* @author thill
* @version 2017.11.14
*/
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
AliasConfig aliasConfig = req.getCore().getAliasConfig();
HashMap<String, HashMap<String, String>> aliases = aliasConfig.getAliases();
SolrParams params = req.getParams();
Iterator<String> pnit = params.getParameterNamesIterator();
Map<String, String[]> modifiedParams = new HashMap<String, String[]>();
String paramnames = "";
while(pnit.hasNext()) {
String pname = pnit.next();
paramnames += pname + " ";
String[] pvalues = params.getParams(pname);
if(!pname.equals("q") && !pname.equals("fq")) {
modifiedParams.put(pname, pvalues);
}
else {
String[] modifiedValues = this.modifyValues(aliases, pvalues);
modifiedParams.put(pname, modifiedValues);
}
}
MultiMapSolrParams newParams = new MultiMapSolrParams(modifiedParams);
req.setParams(newParams);
// a little debugging check
//String paramCheck = outputParams(newParams);
// rsp.add("test", paramCheck);
super.handleRequestBody(req, rsp);
}
示例13: getDictionaryNames
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private String[] getDictionaryNames(SolrParams params) {
String[] dictName = params.getParams(SPELLCHECK_DICT);
if (dictName == null) {
return new String[] {SolrSpellChecker.DEFAULT_DICTIONARY_NAME};
}
return dictName;
}
示例14: parse
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
void parse(SolrParams params, ResponseBuilder rb) {
statsFields = new HashMap<>();
String[] statsFs = params.getParams(StatsParams.STATS_FIELD);
if (statsFs != null) {
for (String field : statsFs) {
boolean calcDistinct = params.getFieldBool(field, StatsParams.STATS_CALC_DISTINCT, false);
SchemaField sf = rb.req.getSchema().getField(field);
statsFields.put(field, StatsValuesFactory.createStatsValues(sf, calcDistinct));
}
}
}
示例15: getSuggesterNames
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private Set<String> getSuggesterNames(SolrParams params) {
Set<String> suggesterNames = new HashSet<>();
String[] suggesterNamesFromParams = params.getParams(SUGGEST_DICT);
if (suggesterNamesFromParams == null) {
suggesterNames.add(DEFAULT_DICT_NAME);
} else {
for (String name : suggesterNamesFromParams) {
suggesterNames.add(name);
}
}
return suggesterNames;
}