本文整理汇总了Java中org.apache.solr.common.params.SolrParams.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java SolrParams.getInt方法的具体用法?Java SolrParams.getInt怎么用?Java SolrParams.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.params.SolrParams
的用法示例。
在下文中一共展示了SolrParams.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void init( final NamedList args ) {
if( args != null ) {
SolrParams params = SolrParams.toSolrParams( args );
maxNumToLog = params.getInt( "maxNumToLog", maxNumToLog );
}
}
示例2: getParser
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
protected SolrPluginUtils.DisjunctionMaxQueryParser getParser(Map<String, Float> fields, String paramName,
SolrParams solrParams, float tiebreaker) {
int slop = solrParams.getInt(paramName, 0);
SolrPluginUtils.DisjunctionMaxQueryParser parser = new SolrPluginUtils.DisjunctionMaxQueryParser(this,
IMPOSSIBLE_FIELD_NAME);
parser.addAlias(IMPOSSIBLE_FIELD_NAME, tiebreaker, fields);
parser.setPhraseSlop(slop);
return parser;
}
示例3: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public XMLLoader init(SolrParams args) {
// Init StAX parser:
inputFactory = XMLInputFactory.newInstance();
EmptyEntityResolver.configureXMLInputFactory(inputFactory);
inputFactory.setXMLReporter(xmllog);
try {
// The java 1.6 bundled stax parser (sjsxp) does not currently have a thread-safe
// XMLInputFactory, as that implementation tries to cache and reuse the
// XMLStreamReader. Setting the parser-specific "reuse-instance" property to false
// prevents this.
// All other known open-source stax parsers (and the bea ref impl)
// have thread-safe factories.
inputFactory.setProperty("reuse-instance", Boolean.FALSE);
} catch (IllegalArgumentException ex) {
// Other implementations will likely throw this exception since "reuse-instance"
// isimplementation specific.
log.debug("Unable to set the 'reuse-instance' property for the input chain: " + inputFactory);
}
// Init SAX parser (for XSL):
saxFactory = SAXParserFactory.newInstance();
saxFactory.setNamespaceAware(true); // XSL needs this!
EmptyEntityResolver.configureSAXParserFactory(saxFactory);
xsltCacheLifetimeSeconds = XSLT_CACHE_DEFAULT;
if(args != null) {
xsltCacheLifetimeSeconds = args.getInt(XSLT_CACHE_PARAM,XSLT_CACHE_DEFAULT);
log.info("xsltCacheLifetimeSeconds=" + xsltCacheLifetimeSeconds);
}
return this;
}
示例4: getAddCommand
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private AddUpdateCommand getAddCommand(SolrQueryRequest req, SolrParams params) {
AddUpdateCommand addCmd = new AddUpdateCommand(req);
addCmd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
addCmd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);
return addCmd;
}
示例5: delete
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private void delete(SolrQueryRequest req, UpdateRequest update, UpdateRequestProcessor processor) throws IOException {
SolrParams params = update.getParams();
DeleteUpdateCommand delcmd = new DeleteUpdateCommand(req);
if(params != null) {
delcmd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);
}
if(update.getDeleteByIdMap() != null) {
Set<Entry<String,Map<String,Object>>> entries = update.getDeleteByIdMap().entrySet();
for (Entry<String,Map<String,Object>> e : entries) {
delcmd.id = e.getKey();
Map<String,Object> map = e.getValue();
if (map != null) {
Long version = (Long) map.get("ver");
if (version != null) {
delcmd.setVersion(version);
}
}
processor.processDelete(delcmd);
delcmd.clear();
}
}
if(update.getDeleteQuery() != null) {
for (String s : update.getDeleteQuery()) {
delcmd.query = s;
processor.processDelete(delcmd);
}
}
}
示例6: doSnapShoot
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private void doSnapShoot(SolrParams params, SolrQueryResponse rsp,
SolrQueryRequest req) {
try {
int numberToKeep = params.getInt(NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM, 0);
if (numberToKeep > 0 && numberBackupsToKeep > 0) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Cannot use "
+ NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM + " if "
+ NUMBER_BACKUPS_TO_KEEP_INIT_PARAM
+ " was specified in the configuration.");
}
numberToKeep = Math.max(numberToKeep, numberBackupsToKeep);
if (numberToKeep < 1) {
numberToKeep = Integer.MAX_VALUE;
}
IndexDeletionPolicyWrapper delPolicy = core.getDeletionPolicy();
IndexCommit indexCommit = delPolicy.getLatestCommit();
if (indexCommit == null) {
indexCommit = req.getSearcher().getIndexReader().getIndexCommit();
}
// small race here before the commit point is saved
SnapShooter snapShooter = new SnapShooter(core, params.get("location"), params.get("name"));
snapShooter.validateCreateSnapshot();
snapShooter.createSnapAsync(indexCommit, numberToKeep, this);
} catch (Exception e) {
LOG.warn("Exception during creating a snapshot", e);
rsp.add("exception", e);
}
}
示例7: updateCommit
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Modify UpdateCommand based on request parameters
*/
public static void updateCommit(CommitUpdateCommand cmd, SolrParams params) {
if( params == null ) return;
cmd.openSearcher = params.getBool( UpdateParams.OPEN_SEARCHER, cmd.openSearcher );
cmd.waitSearcher = params.getBool( UpdateParams.WAIT_SEARCHER, cmd.waitSearcher );
cmd.softCommit = params.getBool( UpdateParams.SOFT_COMMIT, cmd.softCommit );
cmd.expungeDeletes = params.getBool( UpdateParams.EXPUNGE_DELETES, cmd.expungeDeletes );
cmd.maxOptimizeSegments = params.getInt( UpdateParams.MAX_OPTIMIZE_SEGMENTS, cmd.maxOptimizeSegments );
cmd.prepareCommit = params.getBool( UpdateParams.PREPARE_COMMIT, cmd.prepareCommit );
}
示例8: finishStage
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Used in Distributed Search, merges the suggestion results from every shard
* */
@Override
public void finishStage(ResponseBuilder rb) {
SolrParams params = rb.req.getParams();
LOG.info("SuggestComponent finishStage with : " + params);
if (!params.getBool(COMPONENT_NAME, false) || rb.stage != ResponseBuilder.STAGE_GET_FIELDS)
return;
int count = params.getInt(SUGGEST_COUNT, 1);
List<SuggesterResult> suggesterResults = new ArrayList<>();
// Collect Shard responses
for (ShardRequest sreq : rb.finished) {
for (ShardResponse srsp : sreq.responses) {
NamedList<Object> resp;
if((resp = srsp.getSolrResponse().getResponse()) != null) {
@SuppressWarnings("unchecked")
Map<String, SimpleOrderedMap<NamedList<Object>>> namedList =
(Map<String, SimpleOrderedMap<NamedList<Object>>>) resp.get(SuggesterResultLabels.SUGGEST);
LOG.info(srsp.getShard() + " : " + namedList);
suggesterResults.add(toSuggesterResult(namedList));
}
}
}
// Merge Shard responses
SuggesterResult suggesterResult = merge(suggesterResults, count);
Map<String, SimpleOrderedMap<NamedList<Object>>> namedListResults =
new HashMap<>();
toNamedList(suggesterResult, namedListResults);
rb.rsp.add(SuggesterResultLabels.SUGGEST, namedListResults);
}
示例9: processGetVersions
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public void processGetVersions(ResponseBuilder rb) throws IOException
{
SolrQueryRequest req = rb.req;
SolrQueryResponse rsp = rb.rsp;
SolrParams params = req.getParams();
if (!params.getBool(COMPONENT_NAME, true)) {
return;
}
int nVersions = params.getInt("getVersions", -1);
if (nVersions == -1) return;
String sync = params.get("sync");
if (sync != null) {
processSync(rb, nVersions, sync);
return;
}
UpdateLog ulog = req.getCore().getUpdateHandler().getUpdateLog();
if (ulog == null) return;
UpdateLog.RecentUpdates recentUpdates = ulog.getRecentUpdates();
try {
rb.rsp.add("versions", recentUpdates.getVersions(nVersions));
} finally {
recentUpdates.close(); // cache this somehow?
}
}
示例10: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
SolrParams p = new MapSolrParams(args);
dimension = p.getInt(DIMENSION, DEFAULT_DIMENSION);
if (dimension < 1) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"The dimension must be > 0: " + dimension);
}
args.remove(DIMENSION);
super.init(schema, args);
// cache suffixes
createSuffixCache(dimension);
}
示例11: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void init(NamedList args) {
super.init(args);
SolrParams params = SolrParams.toSolrParams( args );
maxChunk = params.getInt("maxChunkSize", MMapDirectory.DEFAULT_MAX_BUFF);
if (maxChunk <= 0){
throw new IllegalArgumentException("maxChunk must be greater than 0");
}
unmapHack = params.getBool("unmap", true);
}
示例12: assertFullWalkNoDups
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Given a set of params, executes a cursor query using {@link #CURSOR_MARK_START}
* and then continuously walks the results using {@link #CURSOR_MARK_START} as long
* as a non-0 number of docs ar returned. This method records the the set of all id's
* (must be positive ints) encountered and throws an assertion failure if any id is
* encountered more than once, or if the set grows above maxSize
*/
public SentinelIntSet assertFullWalkNoDups(int maxSize, SolrParams params)
throws Exception {
SentinelIntSet ids = new SentinelIntSet(maxSize, -1);
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
String json = assertJQ(req(params,
CURSOR_MARK_PARAM, cursorMark));
Map rsp = (Map) ObjectBuilder.fromJSON(json);
assertTrue("response doesn't contain " + CURSOR_MARK_NEXT + ": " + json,
rsp.containsKey(CURSOR_MARK_NEXT));
String nextCursorMark = (String)rsp.get(CURSOR_MARK_NEXT);
assertNotNull(CURSOR_MARK_NEXT + " is null", nextCursorMark);
List<Map<Object,Object>> docs = (List) (((Map)rsp.get("response")).get("docs"));
docsOnThisPage = docs.size();
if (null != params.getInt(CommonParams.ROWS)) {
int rows = params.getInt(CommonParams.ROWS);
assertTrue("Too many docs on this page: " + rows + " < " + docsOnThisPage,
docsOnThisPage <= rows);
}
if (0 == docsOnThisPage) {
assertEquals("no more docs, but "+CURSOR_MARK_NEXT+" isn't same",
cursorMark, nextCursorMark);
}
for (Map<Object,Object> doc : docs) {
int id = ((Long)doc.get("id")).intValue();
assertFalse("walk already seen: " + id, ids.exists(id));
ids.put(id);
assertFalse("id set bigger then max allowed ("+maxSize+"): " + ids.size(),
maxSize < ids.size());
}
cursorMark = nextCursorMark;
}
return ids;
}
示例13: handleUrlSearch
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
* Searches for an image given by an URL. Note that (i) extracting image features takes time and
* (ii) not every image is readable by Java.
*
* @param req
* @param rsp
* @throws IOException
* @throws InstantiationException
* @throws IllegalAccessException
*/
private void handleUrlSearch(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, InstantiationException, IllegalAccessException {
SolrParams params = req.getParams();
String paramUrl = params.get("url");
String paramField = req.getParams().get("field", "cl_ha");
if (!paramField.endsWith("_ha")) paramField += "_ha";
int paramRows = params.getInt("rows", defaultNumberOfResults);
numberOfQueryTerms = req.getParams().getDouble("accuracy", DEFAULT_NUMBER_OF_QUERY_TERMS);
numberOfCandidateResults = req.getParams().getInt("candidates", DEFAULT_NUMBER_OF_CANDIDATES);
useMetricSpaces = req.getParams().getBool("ms", DEFAULT_USE_METRIC_SPACES);
GlobalFeature feat = null;
int[] hashes = null;
Query query = null;
// wrapping the whole part in the try
try {
BufferedImage img = ImageIO.read(new URL(paramUrl).openStream());
img = ImageUtils.trimWhiteSpace(img);
// getting the right feature per field:
if (FeatureRegistry.getClassForHashField(paramField) == null) // if the feature is not registered.
feat = new ColorLayout();
else {
feat = (GlobalFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
}
feat.extract(img);
if (!useMetricSpaces) {
// Re-generating the hashes to save space (instead of storing them in the index)
HashTermStatistics.addToStatistics(req.getSearcher(), paramField);
hashes = BitSampling.generateHashes(feat.getFeatureVector());
query = createQuery(hashes, paramField, numberOfQueryTerms);
} else if (MetricSpaces.supportsFeature(feat)) {
// ----< Metric Spaces >-----
int queryLength = (int) StatsUtils.clamp(numberOfQueryTerms * MetricSpaces.getPostingListLength(feat), 3, MetricSpaces.getPostingListLength(feat));
String msQuery = MetricSpaces.generateBoostedQuery(feat, queryLength);
QueryParser qp = new QueryParser(paramField.replace("_ha", "_ms"), new WhitespaceAnalyzer());
query = qp.parse(msQuery);
} else {
rsp.add("Error", "Feature not supported by MetricSpaces: " + feat.getClass().getSimpleName());
query = new MatchAllDocsQuery();
}
} catch (Exception e) {
rsp.add("Error", "Error reading image from URL: " + paramUrl + ": " + e.getMessage());
e.printStackTrace();
}
// search if the feature has been extracted and query is there.
if (feat != null && query != null) {
doSearch(req, rsp, req.getSearcher(), paramField, paramRows, getFilterQueries(req), query, feat);
}
}
示例14: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void init(NamedList n) {
final SolrParams p = SolrParams.toSolrParams(n);
xsltCacheLifetimeSeconds = p.getInt(XSLT_CACHE_PARAM,XSLT_CACHE_DEFAULT);
log.info("xsltCacheLifetimeSeconds=" + xsltCacheLifetimeSeconds);
}
示例15: init
import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void init(SolrParams params) {
quantRate = params.getFloat("quantRate", 0.01f);
minTokenLen = params.getInt("minTokenLen", 2);
}