本文整理汇总了Java中org.apache.solr.common.util.SimpleOrderedMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleOrderedMap.get方法的具体用法?Java SimpleOrderedMap.get怎么用?Java SimpleOrderedMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.SimpleOrderedMap
的用法示例。
在下文中一共展示了SimpleOrderedMap.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubdocumentCounts
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
public static Map<Integer,Integer> getSubdocumentCounts(SolrResponse response) {
//check if there are subdocs
if (Objects.nonNull(response.getResponse())) {
final Object subDocumentFacetResult = response.getResponse().get("facets");
if (Objects.nonNull(subDocumentFacetResult)) {
Map<Integer,Integer> childCounts = new HashMap<>();
log.debug("Parsing subdocument facet result from JSON ");
final int facetCount = (int) ((SimpleOrderedMap) subDocumentFacetResult).get("count");
if (facetCount > 0) {
final SimpleOrderedMap parentDocs = ((SimpleOrderedMap) ((SimpleOrderedMap) subDocumentFacetResult).get("childrenCount"));
final Integer childCount = (Integer) parentDocs.get("count");
final Integer parentCount;
if(childCount > 0) {
parentCount =(Integer)((SimpleOrderedMap)((List)((SimpleOrderedMap)parentDocs.get("parentFilteredCount")).get("buckets")).get(0)).get("count");
} else {
parentCount = 0;
}
childCounts.put(parentCount, childCount);
}
return childCounts;
}
}
return null;
}
示例2: getMapValue
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
public SimpleOrderedMap<String> getMapValue(SimpleOrderedMap<Object> bucket) {
SimpleOrderedMap<String> result = null;
if(facetFieldExtension != null && !facetFieldExtension.equals("")) {
result = new SimpleOrderedMap<>();
String value = (String) bucket.get("val");
String[] facetFieldKeys = facetFieldExtension.split(facetFieldDelimiter);
String[] facetFieldValues = value.split("\\"+facetFieldValueDelimiter);
for (int i = 0; i < facetFieldKeys.length && i < facetFieldValues.length; ++i) {
if(!facetFieldValues.equals("")) {
result.add(facetFieldKeys[i], facetFieldValues[i]);
}
}
}
return result;
}
示例3: getStringValue
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
public String getStringValue(SimpleOrderedMap<Object> bucket)
{
SimpleOrderedMap<String> mapValues = getMapValue(bucket);
if(mapValues == null)
{
return ((String) bucket.get("val")).replace(facetFieldValueDelimiter, " ");
}
return mapValues.get(this.facetFieldKey);
}
示例4: parseResponse
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
private void parseResponse(SolrQueryResponse resp) {
SimpleOrderedMap<Object> facet = (SimpleOrderedMap<Object>)
((SimpleOrderedMap<Object>)((SimpleOrderedMap<Object>) resp.getValues()).get("facets")).get(QUERY_FACET_NAME);
if(facet != null) {
SimpleOrderedMap<Object> innerFacet = (SimpleOrderedMap<Object>)facet.get(FIELD_FACET_NAME);
if(innerFacet != null)
{
buckets = (List<SimpleOrderedMap<Object>>)innerFacet.get("buckets");
} else {
buckets = new LinkedList<>();
}
} else {
buckets = new LinkedList<>();
}
}
示例5: parseSuggestions
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
protected List<SuggestItem> parseSuggestions(String query, NamedList<SimpleOrderedMap<?>> suggest) {
List<SuggestItem> ret = new ArrayList<>();
if (suggest == null) return ret;
// for each suggestion, get the term
for (Map.Entry entry : suggest) {
String origTerm = (String) entry.getKey();
origTerm = origTerm.replace("\\ ", " ");
if (!(entry.getValue() instanceof SimpleOrderedMap)) continue;
SimpleOrderedMap val = (SimpleOrderedMap) entry.getValue();
// the suggestion may be under suggestions (from suggester module) or suggestion (spell module)
ArrayList<SimpleOrderedMap> suggestions = (ArrayList<SimpleOrderedMap>) val.get("suggestions");
if (suggestions == null) continue;
// for each suggestion, replace the original phrase out of the query with the suggestion
for (SimpleOrderedMap obj : suggestions) {
String sugTerm = (String) obj.get("term");
// replace term seperator with ' ' and remove any term highlighting (<b> tags)
sugTerm = sugTerm.replace('\u001e', ' ').replace("<b>", "").replace("</b>", "");
ret.add(new SuggestItem(sugTerm, sugTerm, "Suggestion"));
}
}
return ret;
}
示例6: test
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
assertU(adoc("id", "1", "title", "this is title", "body", "this is body"));
assertU(commit());
/*
* command=extract
*/
SolrQueryRequest req = req("command", "extract", "conf", "ltr_features.conf");
FeaturesRequestHandler handler = new FeaturesRequestHandler();
SimpleOrderedMap<Object> results = new SimpleOrderedMap<Object>();
handler.handleExtract(req,
makeStream("{\n" +
" \"idField\": \"id\",\n" +
" \"queries\": [\n" +
" {\n" +
" \"qid\": 101,\n" +
" \"query\": \"this\",\n" +
" \"docs\": [ \"1\" ]\n" +
" },\n" +
" {\n" +
" \"qid\": 102,\n" +
" \"query\": \"title\",\n" +
" \"docs\": [ \"1\" ]\n" +
" },\n" +
" {\n" +
" \"qid\": 103,\n" +
" \"query\": \"body\",\n" +
" \"docs\": [ \"1\" ]\n" +
" }\n" +
" ]\n" +
"}\n"), results);
long procId = (Long)results.get("procId");
req.close();
/*
* command=progress
*/
SolrQueryRequest req2 = req("command", "progress", "procId", Long.toString(procId));
results = new SimpleOrderedMap<Object>();
handler.handleProgress(req2, results);
long procId2 = (Long)results.get("procId");
assertEquals(procId, procId2);
assertNotNull(results.get("done?"));
assertNotNull(results.get("progress"));
req2.close();
/*
* command=delete
*/
SolrQueryRequest req3 = req("command", "delete", "procId", Long.toString(procId));
results = new SimpleOrderedMap<Object>();
handler.handleDelete(req3, results);
long procId3 = (Long)results.get("procId");
assertEquals(procId, procId3);
assertNotNull(results.get("result"));
req3.close();
/*
* command=progress => procId is no longer valid
*/
SolrQueryRequest req4 = req("command", "progress", "procId", Long.toString(procId));
results = new SimpleOrderedMap<Object>();
try {
handler.handleProgress(req4, results);
fail("this method should fail because the process is no longer valid");
}
catch (SolrException expected){}
finally {
req4.close();
}
}
示例7: doDistribDates
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
private void doDistribDates(FacetInfo fi, NamedList facet_counts) {
@SuppressWarnings("unchecked")
SimpleOrderedMap<SimpleOrderedMap<Object>> facet_dates =
(SimpleOrderedMap<SimpleOrderedMap<Object>>)
facet_counts.get("facet_dates");
if (facet_dates != null) {
// go through each facet_date
for (Map.Entry<String,SimpleOrderedMap<Object>> entry : facet_dates) {
final String field = entry.getKey();
if (fi.dateFacets.get(field) == null) {
// first time we've seen this field, no merging
fi.dateFacets.add(field, entry.getValue());
} else {
// not the first time, merge current field
SimpleOrderedMap<Object> shardFieldValues
= entry.getValue();
SimpleOrderedMap<Object> existFieldValues
= fi.dateFacets.get(field);
for (Map.Entry<String,Object> existPair : existFieldValues) {
final String key = existPair.getKey();
if (key.equals("gap") ||
key.equals("end") ||
key.equals("start")) {
// we can skip these, must all be the same across shards
continue;
}
// can be null if inconsistencies in shards responses
Integer newValue = (Integer) shardFieldValues.get(key);
if (null != newValue) {
Integer oldValue = ((Integer) existPair.getValue());
existPair.setValue(oldValue + newValue);
}
}
}
}
}
}
示例8: returnFields
import org.apache.solr.common.util.SimpleOrderedMap; //导入方法依赖的package包/类
private void returnFields(ResponseBuilder rb, ShardRequest sreq) {
// Keep in mind that this could also be a shard in a multi-tiered system.
// TODO: if a multi-tiered system, it seems like some requests
// could/should bypass middlemen (like retrieving stored fields)
// TODO: merge fsv to if requested
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) {
boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName();
boolean removeKeyField = !rb.rsp.getReturnFields().wantsField(keyFieldName);
for (ShardResponse srsp : sreq.responses) {
if (srsp.getException() != null) {
// Don't try to get the documents if there was an exception in the shard
if(rb.req.getParams().getBool(ShardParams.SHARDS_INFO, false)) {
@SuppressWarnings("unchecked")
NamedList<Object> shardInfo = (NamedList<Object>) rb.rsp.getValues().get(ShardParams.SHARDS_INFO);
@SuppressWarnings("unchecked")
SimpleOrderedMap<Object> nl = (SimpleOrderedMap<Object>) shardInfo.get(srsp.getShard());
if (nl.get("error") == null) {
// Add the error to the shards info section if it wasn't added before
Throwable t = srsp.getException();
if(t instanceof SolrServerException) {
t = ((SolrServerException)t).getCause();
}
nl.add("error", t.toString() );
StringWriter trace = new StringWriter();
t.printStackTrace(new PrintWriter(trace));
nl.add("trace", trace.toString() );
}
}
continue;
}
SolrDocumentList docs = (SolrDocumentList) srsp.getSolrResponse().getResponse().get("response");
for (SolrDocument doc : docs) {
Object id = doc.getFieldValue(keyFieldName);
ShardDoc sdoc = rb.resultIds.get(id.toString());
if (sdoc != null) {
if (returnScores) {
doc.setField("score", sdoc.score);
} else {
// Score might have been added (in createMainQuery) to shard-requests (and therefore in shard-response-docs)
// Remove score if the outer request did not ask for it returned
doc.remove("score");
}
if (removeKeyField) {
doc.removeFields(keyFieldName);
}
rb._responseDocs.set(sdoc.positionInResponse, doc);
}
}
}
}
}