本文整理汇总了Java中org.apache.solr.common.params.SolrParams.get方法的典型用法代码示例。如果您正苦于以下问题:Java SolrParams.get方法的具体用法?Java SolrParams.get怎么用?Java SolrParams.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.params.SolrParams
的用法示例。
在下文中一共展示了SolrParams.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkParams
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private boolean checkParams(SolrParams params){
if(params.get(config_query_method) == null){
return false;
}
String type;
if((type = params.get(config_api_type)) != null){
if(type.equals("mock")){
return true;
}
if(type.equals("real")) {
if(params.get(config_url) != null){
return true;
}
}
}
return false;
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:21,代码来源:SimilarityParser.java
示例2: relaxMM
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public String relaxMM(SolrParams params, String relaxedMM) {
String query = params.get(CommonParams.Q);
String field = params.get(RelaxerParams.QUERY_RELAXER_FIELD);
Matcher matcher = SUB_QUERY.matcher(query);
while (matcher.find()) {
String subQuery = matcher.group();
String relax = match(RELAX, subQuery);
int start = matcher.start();
if ("ON".equalsIgnoreCase(relax)) {
return replaceOrInsert(MM, query, start, subQuery, relaxedMM);
}
String queryFields = match(QUERY_FIELDS, subQuery);
if (queryFields != null) {
Set<String> fields = matchAll(FIELDS, queryFields);
if (fields.contains(field)) {
return replaceOrInsert(MM, query, start, subQuery, relaxedMM);
}
}
}
return query;
}
示例3: doFetch
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public boolean doFetch(SolrParams solrParams, boolean forceReplication) {
String masterUrl = solrParams == null ? null : solrParams.get(MASTER_URL);
if (!snapPullLock.tryLock())
return false;
try {
tempSnapPuller = snapPuller;
if (masterUrl != null) {
NamedList<Object> nl = solrParams.toNamedList();
nl.remove(SnapPuller.POLL_INTERVAL);
tempSnapPuller = new SnapPuller(nl, this, core);
}
return tempSnapPuller.fetchLatestIndex(core, forceReplication);
} catch (Exception e) {
SolrException.log(LOG, "SnapPull failed ", e);
} finally {
if (snapPuller != null) {
tempSnapPuller = snapPuller;
}
snapPullLock.unlock();
}
return false;
}
示例4: handleRequestBufferUpdatesAction
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private void handleRequestBufferUpdatesAction(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.NAME, "");
log.info("Starting to buffer updates on core:" + cname);
try (SolrCore core = coreContainer.getCore(cname)) {
if (core == null)
throw new SolrException(ErrorCode.BAD_REQUEST, "Core [" + cname + "] does not exist");
UpdateLog updateLog = core.getUpdateHandler().getUpdateLog();
if (updateLog.getState() != UpdateLog.State.ACTIVE) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Core " + cname + " not in active state");
}
updateLog.bufferUpdates();
rsp.add("core", cname);
rsp.add("status", "BUFFERING");
} catch (Throwable e) {
if (e instanceof SolrException)
throw (SolrException)e;
else
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not start buffering updates", e);
} finally {
if (req != null) req.close();
}
}
示例5: preDecorateResponse
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public static void preDecorateResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
// setup response header
final NamedList<Object> responseHeader = new SimpleOrderedMap<>();
rsp.add("responseHeader", responseHeader);
// toLog is a local ref to the same NamedList used by the response
NamedList<Object> toLog = rsp.getToLog();
// for back compat, we set these now just in case other code
// are expecting them during handleRequest
toLog.add("webapp", req.getContext().get("webapp"));
toLog.add("path", req.getContext().get("path"));
final SolrParams params = req.getParams();
final String lpList = params.get(CommonParams.LOG_PARAMS_LIST);
if (lpList == null) {
toLog.add("params", "{" + req.getParamString() + "}");
} else if (lpList.length() > 0) {
toLog.add("params", "{" + params.toFilteredSolrParams(Arrays.asList(lpList.split(","))).toString() + "}");
}
}
示例6: create
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
Object val = value;
if( val == null ) {
String v = params.get("v");
if( v == null ) {
val = defaultValue;
}
else {
val = getObjectFrom(v, params.get("t"));
}
if( val == null ) {
throw new SolrException( ErrorCode.BAD_REQUEST,
"ValueAugmenter is missing a value -- should be defined in solrconfig or inline" );
}
}
return new ValueAugmenter( field, val );
}
示例7: getQueryFromSpatialArgs
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private Query getQueryFromSpatialArgs(QParser parser, SchemaField field, SpatialArgs spatialArgs) {
T strategy = getStrategy(field.getName());
SolrParams localParams = parser.getLocalParams();
String scoreParam = (localParams == null ? null : localParams.get(SCORE_PARAM));
//We get the valueSource for the score then the filter and combine them.
ValueSource valueSource = getValueSourceFromSpatialArgs(parser, field, spatialArgs, scoreParam, strategy);
if (valueSource == null) {
//FYI Solr FieldType doesn't have a getFilter(). We'll always grab
// getQuery() but it's possible a strategy has a more efficient getFilter
// that could be wrapped -- no way to know.
//See SOLR-2883 needScore
return strategy.makeQuery(spatialArgs); //ConstantScoreQuery
}
FunctionQuery functionQuery = new FunctionQuery(valueSource);
if (localParams != null && !localParams.getBool(FILTER_PARAM, true))
return functionQuery;
Filter filter = strategy.makeFilter(spatialArgs);
return new FilteredQuery(functionQuery, filter);
}
示例8: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void init(NamedList initArgs) {
SolrParams params = SolrParams.toSolrParams(initArgs);
String modelDirectory = params.get("modelDirectory",
System.getProperty("model.dir"));//<co id="qqpp.model"/>
String wordnetDirectory = params.get("wordnetDirectory",
System.getProperty("wordnet.dir"));//<co id="qqpp.wordnet"/>
if (modelDirectory != null) {
File modelsDir = new File(modelDirectory);
try {
InputStream chunkerStream = new FileInputStream(
new File(modelsDir,"en-chunker.bin"));
ChunkerModel chunkerModel = new ChunkerModel(chunkerStream);
chunker = new ChunkerME(chunkerModel); //<co id="qqpp.chunker"/>
InputStream posStream = new FileInputStream(
new File(modelsDir,"en-pos-maxent.bin"));
POSModel posModel = new POSModel(posStream);
tagger = new POSTaggerME(posModel); //<co id="qqpp.tagger"/>
// model = new DoccatModel(new FileInputStream( //<co id="qqpp.theModel"/>
// new File(modelDirectory,"en-answer.bin"))).getMaxentModel();
model = new SuffixSensitiveGISModelReader(new File(modelDirectory+"/qa/ans.bin")).getModel();
//GISModel m = new SuffixSensitiveGISModelReader(new File(modelFileName)).getModel();
probs = new double[model.getNumOutcomes()];
atcg = new AnswerTypeContextGenerator(
new File(wordnetDirectory, "dict"));//<co id="qqpp.context"/>
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
示例9: getFieldList
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private String[] getFieldList(String key, SolrParams params) {
final String fieldList = params.get(key);
if(fieldList != null && fieldList.trim().length() > 0) {
String[] fields = splitList.split(fieldList);
if(fields != null){
return fields;
}
}
return null;
}
示例10: SimilarityParser
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public SimilarityParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
super(qstr, localParams, params, req);
//
// create api access via parameters
//
if(!checkParams(params)){
throw new RuntimeException("[SimilarityParser] Params missing in configuration");
}
if(params.get(config_fail) != null && params.getBool(config_fail)){
failOnConnectionError = true;
}
if(params.get(config_api_type).equals("mock")){
similarityApi = new SimilarityApiMock();
}
else {
similarityApi = new SimilarityApi(params.get(config_url), params.get(config_optionalParams));
}
if(params.get(config_query_method).equals("GT")){
modelMethod = AugmentedTermQuery.ModelMethod.Generalized;
}else{
modelMethod = AugmentedTermQuery.ModelMethod.Extended;
}
if(logger.isInfoEnabled()) {
logger.info("Class initialized with: " + similarityApi.getClass().getSimpleName());
}
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:31,代码来源:SimilarityParser.java
示例11: handleRequestBody
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
rsp.setHttpCaching(false);
final SolrParams solrParams = req.getParams();
String dicPath = solrParams.get("dicPath");
Dictionary dict = Utils.getDict(dicPath, loader);
NamedList<Object> result = new NamedList<Object>();
result.add("dicPath", dict.getDicPath().toURI());
boolean check = solrParams.getBool("check", false); //仅仅用于检测词库是否有变化
//用于尝试加载词库,有此参数, check 参数可以省略。
boolean reload = solrParams.getBool("reload", false);
check |= reload;
boolean changed = false;
boolean reloaded = false;
if(check) {
changed = dict.wordsFileIsChange();
result.add("changed", changed);
}
if(changed && reload) {
reloaded = dict.reload();
result.add("reloaded", reloaded);
}
rsp.add("result", result);
}
示例12: relaxQuery
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public String relaxQuery(SolrParams params, String userQuery, String relaxedUserQuery) {
String query = params.get(CommonParams.Q);
String q = params.get(RelaxerParams.QUERY_RELAXER_Q);
if (q != null) {
return query.replaceFirst(RELAXER_QUERY, relaxedUserQuery);
}
return relax(params, userQuery, relaxedUserQuery, query);
}
示例13: performHighlighting
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void performHighlighting(ReSearcherRequestContext ctx, ResponseBuilder rb) {
// check if highlighting is needed
SolrParams params = rb.req.getParams();
String highlightRemoved = params.get(RES_HIGHLIGHT_REMOVED_TAG_PARAM_NAME);
String highlightReplaced = params.get(RES_HIGHLIGHT_REPLACED_TAG_PARAM_NAME);
boolean ignoreQuotes = params.get(RES_HIGHLIGHT_IGNORE_QUOTES_PARAM_NAME, "true").equals("true") ? true : false;
if (highlightRemoved == null && highlightReplaced == null) {
// nothing to do, so just return;
return;
}
// else, fetch suggestions produced by the component and perform highlighting
List<String> sugs = (List<String>) rb.rsp.getValues().get(getSuggestionsTagName());
if (sugs == null) {
// if component didn't generate suggestions, there is nothing to highlight
return;
}
List<String> sugsHighlighted = new ArrayList<String>();
for (String sug : sugs) {
sugsHighlighted.add(CorrectionHighlighter.highlightCorrections(ctx.getOriginalQueryString(), sug,
highlightRemoved, highlightReplaced, ignoreQuotes));
}
rb.rsp.getValues().add(getSuggestionsTagName() + "_highlighted", sugsHighlighted);
}
示例14: prepare
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
String q = params.get(CommonParams.Q);
String bq = null;
if (q == null || q.isEmpty()) {
return;
}
// Segment query and add prefix if a typed segments are found
List<TypedSegment> typedSegments = config.getSegmenter().segment(q);
for (TypedSegment typedSegment : typedSegments) {
FieldMapping mapping = config.getMappings().get(typedSegment.getDictionaryName());
String value = getValue(typedSegment, mapping);
if (mapping.useBoostQuery) {
q = q.replaceAll(typedSegment.getSegment(), "");
bq = String.format("%s:%s", mapping.field, value);
} else {
q = q.replaceAll(typedSegment.getSegment(), String.format("%s:%s", mapping.field, value));
}
}
if (typedSegments.isEmpty()) {
return;
}
// Override q for the "query" component.
ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams(params);
modifiableSolrParams.set(CommonParams.Q, q);
if (bq != null) {
modifiableSolrParams.set(DisMaxParams.BQ, bq);
}
rb.req.setParams(modifiableSolrParams);
}
示例15: prepare
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
String q = params.get(CommonParams.Q);
List<TypedSegment> typedSegments = segmenter.segment(q);
if (typedSegments.isEmpty()) {
return;
}
// If multiple matches, use the closest from the user
CentroidTypedSegment centroidSegment;
if (typedSegments.size() > 1) {
double[] userLatlon = getUserLocation(params);
centroidSegment = getClosestSegment(typedSegments, userLatlon);
} else {
centroidSegment = (CentroidTypedSegment) typedSegments.get(0);
}
// Override point to use the value from the matching centroid.
ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams(params);
modifiableSolrParams.set(SpatialParams.POINT,
String.format("%s,%s", centroidSegment.getLatitude(), centroidSegment.getLongitude()));
q = q.replaceAll(centroidSegment.getSegment(), "");
modifiableSolrParams.set(CommonParams.Q, q);
rb.req.setParams(modifiableSolrParams);
}