本文整理汇总了Java中org.apache.solr.common.util.NamedList.getVal方法的典型用法代码示例。如果您正苦于以下问题:Java NamedList.getVal方法的具体用法?Java NamedList.getVal怎么用?Java NamedList.getVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.NamedList
的用法示例。
在下文中一共展示了NamedList.getVal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMultiMap
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/** Create a Map<String,String[]> from a NamedList */
public static Map<String,String[]> toMultiMap(NamedList params) {
HashMap<String,String[]> map = new HashMap<>();
for (int i=0; i<params.size(); i++) {
String name = params.getName(i);
Object val = params.getVal(i);
if (val instanceof String[]) {
MultiMapSolrParams.addParam(name, (String[]) val, map);
} else if (val instanceof List) {
List l = (List) val;
String[] s = new String[l.size()];
for (int j = 0; j < l.size(); j++) {
s[j] = l.get(j) == null ? null : String.valueOf(l.get(j));
}
MultiMapSolrParams.addParam(name, s, map);
} else {
MultiMapSolrParams.addParam(name, val.toString(), map);
}
}
return map;
}
示例2: toMultiMap
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
static Map<String, String[]> toMultiMap(ModifiableSolrParams solrQueryParameter) {
NamedList<Object> namedList = solrQueryParameter.toNamedList();
//disabled for MCR-953 and https://issues.apache.org/jira/browse/SOLR-7508
//Map<String, String[]> parameters = ModifiableSolrParams.toMultiMap(namedList);
HashMap<String, String[]> parameters = new HashMap<>();
for (int i = 0; i < namedList.size(); i++) {
String name = namedList.getName(i);
Object val = namedList.getVal(i);
if (val instanceof String[]) {
MultiMapSolrParams.addParam(name, (String[]) val, parameters);
} else {
MultiMapSolrParams.addParam(name, val.toString(), parameters);
}
}
//end of fix
return parameters;
}
示例3: iterateOverSpellcheckerSuggestionsForAllIncorrectWords
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Contains logic for iterating over spellchecker's suggestions. If any of input parameters is null, just exits. This method
* iterates over suggestions for ALL incorrectly spelled words. It will not sub-iterate over suggestions of each incorrect
* word, that is the logic which SpellcheckerSuggestionProcessor should take care off.
*
* @param suggestions list of all suggestions, can be extracted with method .extractSpellcheckerSuggestions().
* @param processor instance of processor which will handle all suggestions for word
*/
@SuppressWarnings("unchecked")
public static void iterateOverSpellcheckerSuggestionsForAllIncorrectWords(NamedList suggestions, SpellcheckerSuggestionProcessor processor) {
if (suggestions == null || processor == null) {
return;
}
for (int i = 0; i < suggestions.size(); i++) {
// find first acceptable suggestion
if (suggestions.getVal(i) instanceof SimpleOrderedMap) {
processor.process((SimpleOrderedMap) suggestions.getVal(i), suggestions.getName(i));
}
}
processor.afterProcessingFinished();
}
示例4: Tag
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
Tag(NamedList<Object> res){
for( int i=0; i<res.size(); i++ ) {
String n = res.getName( i );
switch (n) {
case "startOffset":
_start = (Integer)res.getVal(i);
break;
case "endOffset":
_end = (Integer)res.getVal(i);
break;
case "ids":
_ids = (List<Object>)res.getVal(i);
break;
default:
break;
}
}
}
示例5: iterateOverSpellcheckerSuggestionsForWord
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Contains logic for iterating over spellchecker's suggestions. If any of input parameters is null, just exits. This method
* iterates over suggestions for one incorrect word (for which parameter <code>suggestions</code> should contain spellchecker's suggestions).
*
*
* @param suggestions list of suggestions for some word, so word parameter isn't needed
* @param processor instance of processor which will handle all suggestions for word
*/
@SuppressWarnings("unchecked")
public static void iterateOverSpellcheckerSuggestionsForWord(NamedList suggestions, SpellcheckerSuggestionProcessor processor) {
int i = 4;
// double topFreq = 0;
if (suggestions.getVal(4) instanceof List) {
// support for new version of Solr (valid after 2009-09-09 in version 1.4)
List<SimpleOrderedMap> l = (List<SimpleOrderedMap>) suggestions.getVal(4);
i = 0;
while (true) {
if (l.size() <= i) {
break;
}
processor.process(l.get(i), (String) l.get(i).get("word"));
i++;
}
}
else {
// old way, before 2009-09-09
while (true) {
if (suggestions.size() <= i) {
break;
}
processor.process((NamedList) (suggestions).getVal(i), suggestions.getName(i));
i++;
}
}
processor.afterProcessingFinished();
}
示例6: updateExternalRepresentation
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public void updateExternalRepresentation(NamedList<Object> nl) {
for (int i = 0; i < nl.size(); i++) {
String rawName = nl.getName(i);
String externalName = readableToExternal(rawName);
nl.setName(i, externalName);
Object val = nl.getVal(i);
Object updatedVal;
if (!(val instanceof Number) && (updatedVal = updateValueExternalRepresentation(val)) != null) {
nl.setVal(i, updatedVal);
}
}
}
示例7: updateEntry
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public boolean updateEntry(String term, String docId, SolrDocument doc, Deque<Entry<String, Object>> entryBuilder) {
Entry<String, Object> last;
if (!entryBuilder.isEmpty() && term.equals((last = entryBuilder.getLast()).getKey())) {
NamedList<Object> lastVal = (NamedList<Object>)last.getValue();
Deque<Entry<String, Object>> docDeque = (Deque<Entry<String, Object>>) lastVal.getVal(lastVal.size() - 1);
docDeque.addLast(new SimpleImmutableEntry<>(docId, doc));
return true;
}
return false;
}
示例8: removeTail
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public void removeTail(Deque<Entry<String, Object>> entryBuilder) {
Entry<String, Object> first = entryBuilder.getFirst();
NamedList<Object> firstVal = (NamedList<Object>)first.getValue();
Deque<Entry<String, Object>> docDeque = (Deque<Entry<String, Object>>)firstVal.getVal(firstVal.size() - 1);
if (docDeque.size() > 1) {
docDeque.removeFirst();
} else {
entryBuilder.removeFirst();
}
}
示例9: finalize
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public NamedList<Object> finalize(NamedList<Object> ret) {
ret = super.finalize(ret);
for (int i = 0; i < ret.size(); i++) {
NamedList<Object> termEntry = (NamedList<Object>)ret.getVal(i);
int docsIdx = termEntry.size() - 1;
Deque<Entry<String, SolrDocument>> docDeque = (Deque<Entry<String, SolrDocument>>)termEntry.getVal(docsIdx);
NamedList<SolrDocument> docsExternal = new NamedList(docDeque.toArray(new Entry[docDeque.size()]));
termEntry.setVal(docsIdx, docsExternal);
}
return ret;
}
示例10: QuerySegmenterConfig
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public QuerySegmenterConfig(NamedList args) {
segmenter = new QuerySegmenterDefaultImpl();
NamedList segments = (NamedList) args.get(INIT_ATTR_SEGMENTS);
for (int i = 0; i < segments.size(); i++) {
String name = segments.getName(i);
NamedList values = (NamedList) segments.getVal(i);
initSegmentType(name, values);
}
}
示例11: write
import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
* Here the writer creates its output.
*
* @param writer the character stream writer.
* @param request the current {@link SolrQueryRequest}
* @param response the output response.
* @throws IOException in case of I/O failure.
*/
@SuppressWarnings("rawtypes")
@Override
public void write(
final Writer writer,
final SolrQueryRequest request,
final SolrQueryResponse response) throws IOException {
// 1. Get a reference to values that compound the current response
final NamedList elements = response.getValues();
// 2. Use a StringBuilder to build the output
final StringBuilder builder = new StringBuilder("{")
.append("query:'")
.append(request.getParams().get(CommonParams.Q))
.append("',");
// 3. Get a reference to the object which hold the query result
final Object value = elements.getVal(1);
if (value instanceof ResultContext) {
final ResultContext context = (ResultContext) value;
// The ordered list (actually the page subset) of matched documents
final DocList ids = context.getDocList();
if (ids != null) {
final SolrIndexSearcher searcher = request.getSearcher();
final DocIterator iterator = ids.iterator();
builder.append("suggestions:[");
// 4. Iterate over documents
for (int i = 0; i < ids.size(); i++) {
// 5. For each document we need to get the corresponding "label" attribute
final Document document = searcher.doc(iterator.nextDoc(), FIELDS);
if (i > 0) { builder.append(","); }
// 6. Append the label value to writer output
builder
.append("'")
.append(((String) document.get("label")).replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\""))
.append("'");
}
builder.append("]").append("}");
}
}
// 7. and finally write out the built character stream by means of output writer.
writer.write(builder.toString());
}