本文整理汇总了Java中org.apache.solr.common.params.MapSolrParams类的典型用法代码示例。如果您正苦于以下问题:Java MapSolrParams类的具体用法?Java MapSolrParams怎么用?Java MapSolrParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapSolrParams类属于org.apache.solr.common.params包,在下文中一共展示了MapSolrParams类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fetchExistingOrCreateNewSolrDoc
import org.apache.solr.common.params.MapSolrParams; //导入依赖的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!");
}
}
开发者ID:sematext,项目名称:solr-autocomplete,代码行数:23,代码来源:AutocompleteUpdateRequestProcessor.java
示例2: testRelaxMM
import org.apache.solr.common.params.MapSolrParams; //导入依赖的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);
}
开发者ID:sematext,项目名称:solr-researcher,代码行数:17,代码来源:TestRegexExtract.java
示例3: testTransformValue
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
/**
* Test that the ContentHandler properly strips the illegal characters
*/
@Test
public void testTransformValue() {
String fieldName = "user_name";
assertFalse("foobar".equals(getFoobarWithNonChars()));
Metadata metadata = new Metadata();
// load illegal char string into a metadata field and generate a new document,
// which will cause the ContentHandler to be invoked.
metadata.set(fieldName, getFoobarWithNonChars());
StripNonCharSolrContentHandlerFactory contentHandlerFactory =
new StripNonCharSolrContentHandlerFactory(DateUtil.DEFAULT_DATE_FORMATS);
IndexSchema schema = h.getCore().getLatestSchema();
SolrContentHandler contentHandler =
contentHandlerFactory.createSolrContentHandler(metadata, new MapSolrParams(new HashMap()), schema);
SolrInputDocument doc = contentHandler.newDocument();
String foobar = doc.getFieldValue(fieldName).toString();
assertTrue("foobar".equals(foobar));
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrCellMorphlineTest.java
示例4: getLocalParams
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
/**
* "foo" returns null
* "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes"
* "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")
*/
public static SolrParams getLocalParams(String txt, SolrParams params) throws SyntaxError {
if (txt == null || !txt.startsWith(LOCALPARAM_START)) {
return null;
}
Map<String, String> localParams = new HashMap<>();
int start = QueryParsing.parseLocalParams(txt, 0, localParams, params);
String val = localParams.get(V);
if (val == null) {
val = txt.substring(start);
localParams.put(V, val);
} else {
// localParams.put(VAL_EXPLICIT, "true");
}
return new MapSolrParams(localParams);
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:QueryParsing.java
示例5: init
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
super.init(schema, args);
this.schema = schema;
//it's not a first class citizen for the IndexSchema
SolrParams p = new MapSolrParams(args);
subFieldType = p.get(SUB_FIELD_TYPE);
subSuffix = p.get(SUB_FIELD_SUFFIX);
if (subFieldType != null) {
args.remove(SUB_FIELD_TYPE);
subType = schema.getFieldTypeByName(subFieldType.trim());
suffix = POLY_FIELD_SEPARATOR + subType.typeName;
} else if (subSuffix != null) {
args.remove(SUB_FIELD_SUFFIX);
suffix = subSuffix;
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "The field type: " + typeName
+ " must specify the " +
SUB_FIELD_TYPE + " attribute or the " + SUB_FIELD_SUFFIX + " attribute.");
}
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:AbstractSubTypeFieldType.java
示例6: testFieldStatisticsResultsStringField
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsStringField() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1", "active_s", "string1"));
assertU(adoc("id", "2", "active_s", "string2"));
assertU(adoc("id", "3", "active_s", "string3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_s");
args.put("f.active_s.stats.calcdistinct","true");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//str[@name='min'][.='string1']",
"//str[@name='max'][.='string3']",
"//long[@name='count'][.='3']",
"//long[@name='missing'][.='1']",
"//long[@name='countDistinct'][.='3']",
"count(//arr[@name='distinctValues']/str)=3");
}
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:StatsComponentTest.java
示例7: testFieldStatisticsResultsNumericFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsNumericFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_i");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_i'][.='']");
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:StatsComponentTest.java
示例8: testFieldStatisticsResultsStringFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsStringFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_s");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_s'][.='']");
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:StatsComponentTest.java
示例9: testFieldStatisticsResultsDateFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsDateFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_dt");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_dt'][.='']");
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:StatsComponentTest.java
示例10: setUrlScheme
import org.apache.solr.common.params.MapSolrParams; //导入依赖的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);
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SSLMigrationTest.java
示例11: removeAndWaitForReplicaGone
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
protected void removeAndWaitForReplicaGone(String COLL_NAME,
CloudSolrServer client, Replica replica, String shard)
throws SolrServerException, IOException, InterruptedException {
Map m = makeMap("collection", COLL_NAME, "action", DELETEREPLICA, "shard",
shard, "replica", replica.getName());
SolrParams params = new MapSolrParams(m);
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
client.request(request);
long endAt = System.currentTimeMillis() + 3000;
boolean success = false;
DocCollection testcoll = null;
while (System.currentTimeMillis() < endAt) {
testcoll = getCommonCloudSolrServer().getZkStateReader()
.getClusterState().getCollection(COLL_NAME);
success = testcoll.getSlice(shard).getReplica(replica.getName()) == null;
if (success) {
log.info("replica cleaned up {}/{} core {}",
shard + "/" + replica.getName(), replica.getStr("core"));
log.info("current state {}", testcoll);
break;
}
Thread.sleep(100);
}
assertTrue("Replica not cleaned up", success);
}
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:DeleteReplicaTest.java
示例12: setClusterProp
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public static boolean setClusterProp(CloudSolrServer client, String name , String val) throws SolrServerException, IOException, InterruptedException {
Map m = makeMap(
"action", CollectionAction.CLUSTERPROP.toLower(),
"name",name);
if(val != null) m.put("val", val);
SolrRequest request = new QueryRequest(new MapSolrParams(m));
request.setPath("/admin/collections");
client.request(request);
long tomeOut = System.currentTimeMillis() + 3000;
boolean changed = false;
while(System.currentTimeMillis() <tomeOut){
Thread.sleep(10);
changed = Objects.equals(val,client.getZkStateReader().getClusterProps().get(name));
if(changed) break;
}
return changed;
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CollectionsAPIDistributedZkTest.java
示例13: testSourceGlobMatchesNoDynamicOrExplicitField
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
@Test
public void testSourceGlobMatchesNoDynamicOrExplicitField()
{
// SOLR-4650: copyField source globs should not have to match an explicit or dynamic field
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
assertNull("'testing123_*' should not be (or match) a dynamic or explicit field", schema.getFieldOrNull("testing123_*"));
assertTrue("schema should contain dynamic field '*_s'", schema.getDynamicPattern("*_s").equals("*_s"));
assertU(adoc("id", "A5", "sku1", "10-1839ACX-93", "testing123_s", "AAM46"));
assertU(commit());
Map<String,String> args = new HashMap<>();
args.put( CommonParams.Q, "text:AAM46" );
args.put( "indent", "true" );
SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("sku2 copied to text", req
,"//*[@numFound='1']"
,"//result/doc[1]/str[@name='id'][.='A5']"
);
}
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:CopyFieldTest.java
示例14: getLocalParams
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
/**
* "foo" returns null
* "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes"
* "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")
*/
public static SolrParams getLocalParams(String txt, SolrParams params) throws SyntaxError {
if (txt == null || !txt.startsWith(LOCALPARAM_START)) {
return null;
}
Map<String, String> localParams = new HashMap<String, String>();
int start = QueryParsing.parseLocalParams(txt, 0, localParams, params);
String val = localParams.get(V);
if (val == null) {
val = txt.substring(start);
localParams.put(V, val);
} else {
// localParams.put(VAL_EXPLICIT, "true");
}
return new MapSolrParams(localParams);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:22,代码来源:QueryParsing.java
示例15: init
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
this.schema = schema;
//it's not a first class citizen for the IndexSchema
SolrParams p = new MapSolrParams(args);
String subFT = p.get(SUB_FIELD_TYPE);
String subSuffix = p.get(SUB_FIELD_SUFFIX);
if (subFT != null) {
args.remove(SUB_FIELD_TYPE);
subType = schema.getFieldTypeByName(subFT.trim());
suffix = POLY_FIELD_SEPARATOR + subType.typeName;
} else if (subSuffix != null) {
args.remove(SUB_FIELD_SUFFIX);
suffix = subSuffix;
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "The field type: " + typeName
+ " must specify the " +
SUB_FIELD_TYPE + " attribute or the " + SUB_FIELD_SUFFIX + " attribute.");
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:22,代码来源:AbstractSubTypeFieldType.java
示例16: testFieldStatisticsResultsStringField
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsStringField() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1", "active_s", "string1"));
assertU(adoc("id", "2", "active_s", "string2"));
assertU(adoc("id", "3", "active_s", "string3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<String, String>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_s");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//str[@name='min'][.='string1']",
"//str[@name='max'][.='string3']",
"//long[@name='count'][.='3']",
"//long[@name='missing'][.='1']");
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:22,代码来源:StatsComponentTest.java
示例17: testFieldStatisticsResultsNumericFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsNumericFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<String, String>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_i");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_i'][.='']");
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:StatsComponentTest.java
示例18: testFieldStatisticsResultsStringFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsStringFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<String, String>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_s");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_s'][.='']");
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:StatsComponentTest.java
示例19: testFieldStatisticsResultsDateFieldAlwaysMissing
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
public void testFieldStatisticsResultsDateFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(commit());
Map<String, String> args = new HashMap<String, String>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_dt");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req,
"//null[@name='active_dt'][.='']");
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:StatsComponentTest.java
示例20: setTopInitArgsAsInvariants
import org.apache.solr.common.params.MapSolrParams; //导入依赖的package包/类
/**
* This request handler supports configuration options defined at the top
* level as well as those in typical Solr 'defaults', 'appends', and
* 'invariants'. The top level ones are treated as invariants.
*/
private void setTopInitArgsAsInvariants(SolrQueryRequest req) {
// First convert top level initArgs to SolrParams
HashMap<String, String> map = new HashMap<String, String>(initArgs.size());
for (int i = 0; i < initArgs.size(); i++) {
Object val = initArgs.getVal(i);
if (val != null && !(val instanceof NamedList))
map.put(initArgs.getName(i), val.toString());
}
if (map.isEmpty())
return;// short circuit; nothing to do
SolrParams topInvariants = new MapSolrParams(map);
// By putting the top level into the 1st arg, it overrides
// request params in 2nd arg.
req.setParams(SolrParams.wrapDefaults(topInvariants, req.getParams()));
}
开发者ID:ziqizhang,项目名称:jate,代码行数:21,代码来源:TermRecognitionRequestHandler.java
注:本文中的org.apache.solr.common.params.MapSolrParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论