本文整理汇总了Java中org.apache.solr.common.params.SolrParams类的典型用法代码示例。如果您正苦于以下问题:Java SolrParams类的具体用法?Java SolrParams怎么用?Java SolrParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrParams类属于org.apache.solr.common.params包,在下文中一共展示了SolrParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchExistingOrCreateNewSolrDoc
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
private SolrInputDocument fetchExistingOrCreateNewSolrDoc(String id) throws SolrServerException, IOException {
Map<String, String> p = new HashMap<String, String>();
p.put("q", PHRASE + ":\"" + ClientUtils.escapeQueryChars(id) + "\"");
SolrParams params = new MapSolrParams(p);
QueryResponse res = solrAC.query(params);
if (res.getResults().size() == 0) {
return new SolrInputDocument();
} else if (res.getResults().size() == 1) {
SolrDocument doc = res.getResults().get(0);
SolrInputDocument tmp = new SolrInputDocument();
for (String fieldName : doc.getFieldNames()) {
tmp.addField(fieldName, doc.getFieldValue(fieldName));
}
return tmp;
} else {
throw new IllegalStateException("Query with params : " + p + " returned more than 1 hit!");
}
}
示例2: 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
示例3: newFrom
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
/**
* Creates a new {@link SolrQueryRequest} from a given prototype and injects there a set of params.
*
* @param request the prototype {@link SolrQueryRequest}.
* @param params the parameters that will be injected.
* @return a {@link SolrQueryRequest} clone.
*/
public SolrQueryRequest newFrom(final SolrQueryRequest request, final SolrParams params) {
return new SolrQueryRequestBase(
request.getCore(),
new ModifiableSolrParams(params),
new RTimerTree()) {
@Override
public Map<Object, Object> getContext() {
return request.getContext();
}
@Override
public SolrIndexSearcher getSearcher() {
return request.getSearcher();
}
};
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:24,代码来源:InvisibleQueriesRequestHandler.java
示例4: 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;
}
示例5: testRelaxMM
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
@Test
public void testRelaxMM() {
Map<String, String> m = new HashMap<String, String>();
m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on'}\" +yearpub:2008");
SolrParams params = new MapSolrParams(m);
String relaxedQuery = extract.relaxMM(params, "-1");
assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='-1'}\" +yearpub:2008", relaxedQuery);
m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='100%'}\" +yearpub:2008");
relaxedQuery = extract.relaxMM(params, "-1");
assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='-1'}\" +yearpub:2008", relaxedQuery);
m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' mm='100%'}\" +yearpub:2008");
relaxedQuery = extract.relaxMM(params, "-1");
assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' mm='100%'}\" +yearpub:2008", relaxedQuery);
}
示例6: ParsedParams
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
public ParsedParams(final SolrParams localParams, // localParams on this particular facet command
final SolrParams params, // local+original
final SolrParams required, // required version of params
final String facetValue, // the field to or query to facet on (minus local params)
final DocSet docs, // the base docset for this particular facet
final String key, // what name should the results be stored under
final List<String> tags,
final int threads) {
this.localParams = localParams;
this.params = params;
this.required = required;
this.facetValue = facetValue;
this.docs = docs;
this.key = key;
this.tags = tags;
this.threads = threads;
}
示例7: newBytesRefFilter
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
protected Predicate<BytesRef> newBytesRefFilter(String field, SolrParams params) {
final String contains = params.getFieldParam(field, FacetParams.FACET_CONTAINS);
final Predicate<BytesRef> containsFilter;
if (contains != null) {
final boolean containsIgnoreCase = params.getFieldBool(field, FacetParams.FACET_CONTAINS_IGNORE_CASE, false);
containsFilter = new SubstringBytesRefFilter(contains, containsIgnoreCase);
} else {
containsFilter = null;
}
final Predicate<BytesRef> excludeFilter = newExcludeBytesRefFilter(field, params);
if (containsFilter == null && excludeFilter == null) {
return null;
}
if (containsFilter != null && excludeFilter == null) {
return containsFilter;
} else if (containsFilter == null && excludeFilter != null) {
return excludeFilter;
}
return containsFilter.and(excludeFilter);
}
示例8: configure
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
protected void configure(DefaultHttpClient httpClient, SolrParams config) {
super.configure(httpClient, config);
// Begin change for SDC-2962
// Instead of checking existence of JAAS file, do the following if solr kerberos is enabled
//if(System.getProperty("java.security.auth.login.config") != null) {
String basicAuthUser = config.get("httpBasicAuthUser");
String basicAuthPass = config.get("httpBasicAuthPassword");
if(basicAuthUser != null && basicAuthPass != null) {
logger.warn("Setting both SPNego auth and basic auth not supported. Preferring SPNego auth, ignoring basic auth.");
httpClient.getCredentialsProvider().clear();
}
setSPNegoAuth(httpClient);
//}
}
示例9: getParams
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
@Override
public SolrParams getParams() {
if (action == null) {
throw new RuntimeException("no action specified!");
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, action.toString());
params.set(CoreAdminParams.CORE, core);
if (indexDirs != null) {
for (String indexDir : indexDirs) {
params.add(CoreAdminParams.INDEX_DIR, indexDir);
}
}
if (srcCores != null) {
for (String srcCore : srcCores) {
params.add(CoreAdminParams.SRC_CORE, srcCore);
}
}
return params;
}
示例10: fillParams
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
protected void fillParams(ResponseBuilder rb, SolrParams params, String field) {
this.field = field;
this.ftype = rb.req.getSchema().getFieldTypeNoEx(this.field);
this.offset = params.getFieldInt(field, FacetParams.FACET_OFFSET, 0);
this.limit = params.getFieldInt(field, FacetParams.FACET_LIMIT, 100);
Integer mincount = params.getFieldInt(field, FacetParams.FACET_MINCOUNT);
if (mincount == null) {
Boolean zeros = params.getFieldBool(field, FacetParams.FACET_ZEROS);
// mincount = (zeros!=null && zeros) ? 0 : 1;
mincount = (zeros != null && !zeros) ? 1 : 0;
// current default is to include zeros.
}
this.minCount = mincount;
this.missing = params.getFieldBool(field, FacetParams.FACET_MISSING, false);
// default to sorting by count if there is a limit.
this.sort = params.getFieldParam(field, FacetParams.FACET_SORT,
(limit > 0 ?
FacetParams.FACET_SORT_COUNT
: FacetParams.FACET_SORT_INDEX));
if (this.sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY)) {
this.sort = FacetParams.FACET_SORT_COUNT;
} else if (this.sort.equals(FacetParams.FACET_SORT_INDEX_LEGACY)) {
this.sort = FacetParams.FACET_SORT_INDEX;
}
this.prefix = params.getFieldParam(field, FacetParams.FACET_PREFIX);
}
示例11: handleRequestActionStatus
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
/**
* Handle "REQUESTSTATUS" action
*/
protected void handleRequestActionStatus(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String requestId = params.get(CoreAdminParams.REQUESTID);
log.info("Checking request status for : " + requestId);
if (mapContainsTask(RUNNING, requestId)) {
rsp.add(RESPONSE_STATUS, RUNNING);
} else if(mapContainsTask(COMPLETED, requestId)) {
rsp.add(RESPONSE_STATUS, COMPLETED);
rsp.add(RESPONSE, getMap(COMPLETED).get(requestId).getRspObject());
} else if(mapContainsTask(FAILED, requestId)) {
rsp.add(RESPONSE_STATUS, FAILED);
rsp.add(RESPONSE, getMap(FAILED).get(requestId).getRspObject());
} else {
rsp.add(RESPONSE_STATUS, "notfound");
rsp.add(RESPONSE_MESSAGE, "No task found in running, completed or failed tasks");
}
}
示例12: prepare
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
rb.doHighlights = highlighter.isHighlightingEnabled(params);
if(rb.doHighlights){
String hlq = params.get(HighlightParams.Q);
String hlparser = Objects.firstNonNull(params.get(HighlightParams.QPARSER),
params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE));
if(hlq != null){
try {
QParser parser = QParser.getParser(hlq, hlparser, rb.req);
rb.setHighlightQuery(parser.getHighlightQuery());
} catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
}
}
}
示例13: JQ
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
/** Makes a query request and returns the JSON string response */
public static String JQ(SolrQueryRequest req) throws Exception {
SolrParams params = req.getParams();
if (!"json".equals(params.get("wt","xml")) || params.get("indent")==null) {
ModifiableSolrParams newParams = new ModifiableSolrParams(params);
newParams.set("wt","json");
if (params.get("indent")==null) newParams.set("indent","true");
req.setParams(newParams);
}
String response;
boolean failed=true;
try {
response = h.query(req);
failed = false;
} finally {
if (failed) {
log.error("REQUEST FAILED: " + req.getParamString());
}
}
return response;
}
示例14: prepare
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false)) {
return;
}
SolrSpellChecker spellChecker = getSpellChecker(params);
if (params.getBool(SPELLCHECK_BUILD, false)) {
spellChecker.build(rb.req.getCore(), rb.req.getSearcher());
rb.rsp.add("command", "build");
} else if (params.getBool(SPELLCHECK_RELOAD, false)) {
spellChecker.reload(rb.req.getCore(), rb.req.getSearcher());
rb.rsp.add("command", "reload");
}
}
示例15: setUrlScheme
import org.apache.solr.common.params.SolrParams; //导入依赖的package包/类
private void setUrlScheme(String value) throws Exception {
@SuppressWarnings("rawtypes")
Map m = makeMap("action", CollectionAction.CLUSTERPROP.toString()
.toLowerCase(Locale.ROOT), "name", "urlScheme", "val", value);
@SuppressWarnings("unchecked")
SolrParams params = new MapSolrParams(m);
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
List<String> urls = new ArrayList<String>();
for(Replica replica : getReplicas()) {
urls.add(replica.getStr(ZkStateReader.BASE_URL_PROP));
}
//Create new SolrServer to configure new HttpClient w/ SSL config
new LBHttpSolrServer(urls.toArray(new String[]{})).request(request);
}