当前位置: 首页>>代码示例>>Java>>正文


Java NamedList类代码示例

本文整理汇总了Java中org.apache.solr.common.util.NamedList的典型用法代码示例。如果您正苦于以下问题:Java NamedList类的具体用法?Java NamedList怎么用?Java NamedList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NamedList类属于org.apache.solr.common.util包,在下文中一共展示了NamedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listRuntimeDependencies

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
protected List<String> listRuntimeDependencies(String collectionName) throws IOException, SolrServerException {
    ModifiableSolrParams params = new ModifiableSolrParams().set("file",RUNTIME_LIB_FILE_NAME);
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/file");
    request.setResponseParser(new InputStreamResponseParser("json"));

    NamedList o = client.request(request, collectionName);

    LineIterator it = IOUtils.lineIterator((InputStream) o.get("stream"), "utf-8");

    List<String> returnValues = Streams.stream(it).collect(Collectors.toList());

    //if file not exists (a little hacky..)
    if(returnValues.size() == 1 && returnValues.get(0).startsWith("{\"responseHeader\":{\"status\":404")) {
        logger.warn("Release does not yet contain rumtimelib configuration file. Runtimelibs have to be installed manually.");
        return Collections.emptyList();
    };
    return returnValues;
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:20,代码来源:CollectionManagementService.java

示例2: getCores

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
/**
 * Get target cores via CoreAdminAPI.
 *
 * @param httpSolrClient
 * @return
 */
public static List<String> getCores(HttpSolrClient httpSolrClient) throws SolrServerException, IOException {
    List<String> cores = new ArrayList<>();

    NoOpResponseParser responseParser = new NoOpResponseParser();
    responseParser.setWriterType("json");

    httpSolrClient.setParser(responseParser);

    CoreAdminRequest coreAdminRequest = new CoreAdminRequest();
    coreAdminRequest.setAction(CoreAdminParams.CoreAdminAction.STATUS);
    coreAdminRequest.setIndexInfoNeeded(false);

    NamedList<Object> coreAdminResponse = httpSolrClient.request(coreAdminRequest);

    JsonNode statusJsonNode = om.readTree((String) coreAdminResponse.get("response")).get("status");

    for (Iterator<JsonNode> i = statusJsonNode.iterator(); i.hasNext(); ) {
        String core = i.next().get("name").textValue();
        if (!cores.contains(core)) {
            cores.add(core);
        }
    }

    return cores;
}
 
开发者ID:mosuka,项目名称:solr-exporter,代码行数:32,代码来源:SolrCollector.java

示例3: request

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
@Override
public NamedList<Object> request(@SuppressWarnings("rawtypes") SolrRequest req, String collection)
    throws SolrServerException, IOException {
    if (closed) {
        throw new SolrServerException("The SolrClient is closed.");
    }
    if (collection == null) {
        throw new SolrServerException("a collection must be specified");
    }
    String expr = req.getParams().get("expr");
    if (expr == null) {
        throw new SolrServerException(
            "there should be an 'expr' parameter on the request, to specify a streaming expression.");
    }
    String json = JSONUtil.toJSON(root);
    InputStream is = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
    NamedList<Object> nl = new NamedList<>(Collections.singletonMap("stream", is));
    return nl;
}
 
开发者ID:jdyer1,项目名称:R-solr-stream,代码行数:20,代码来源:MockSolrClient.java

示例4: toMultiMap

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
/** Create a Map&lt;String,String[]&gt; 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;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:22,代码来源:SolrParams.java

示例5: toNamedList

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
/** Convert this to a NamedList */
public NamedList<Object> toNamedList() {
    final SimpleOrderedMap<Object> result = new SimpleOrderedMap<>();

    for(Iterator<String> it=getParameterNamesIterator(); it.hasNext(); ) {
        final String name = it.next();
        final String [] values = getParams(name);
        if(values.length==1) {
            result.add(name,values[0]);
        } else {
            // currently no reason not to use the same array
            result.add(name,values);
        }
    }
    return result;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:17,代码来源:SolrParams.java

示例6: SuggestionService

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
public SuggestionService(SolrCore solrCore, NamedList args) {

        NamedList l = new NamedList();

        //set spellcheck component if there is one
        if(((ArrayList)args.get("first-components")).contains("spellcheck")) {
            List component = new ArrayList<String>();
            component.add("spellcheck");
            l.add("first-components",component);
            spellcheck_enabled = true;
        }

        if(args.get("defaults") != null && ((NamedList)args.get("defaults")).get(SuggestionRequestParams.SUGGESTION_INTERNAL_LIMIT) != null) {
            internalFacetLimit = (String)((NamedList)args.get("defaults")).get(SuggestionRequestParams.SUGGESTION_INTERNAL_LIMIT);
        }

        this.solrCore = solrCore;
        this.searchHandler = new SearchHandler();
        this.searchHandler.init(l);
        this.searchHandler.inform(solrCore);
    }
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:22,代码来源:SuggestionService.java

示例7: getCollections

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
/**
 * Get target cores via CollectionsAPI.
 *
 * @param cloudSolrClient
 * @return
 */
public static List<String> getCollections(CloudSolrClient cloudSolrClient) throws SolrServerException, IOException {
    List<String> collections = new ArrayList<>();

    NoOpResponseParser responseParser = new NoOpResponseParser();
    responseParser.setWriterType("json");

    cloudSolrClient.setParser(responseParser);

    CollectionAdminRequest collectionAdminRequest = new CollectionAdminRequest.List();

    NamedList<Object> collectionAdminResponse = cloudSolrClient.request(collectionAdminRequest);

    JsonNode collectionsJsonNode = om.readTree((String) collectionAdminResponse.get("response")).get("collections");

    for (Iterator<JsonNode> i = collectionsJsonNode.iterator(); i.hasNext(); ) {
        String collection = i.next().textValue();
        if (!collections.contains(collection)) {
            collections.add(collection);
        }
    }

    return collections;
}
 
开发者ID:mosuka,项目名称:solr-exporter,代码行数:30,代码来源:SolrCollector.java

示例8: getBaseUrls

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
/**
 * Get base urls via CollectionsAPI.
 *
 * @param cloudSolrClient
 * @return
 */
private List<String> getBaseUrls(CloudSolrClient cloudSolrClient) throws SolrServerException, IOException {
    List<String> baseUrls = new ArrayList<>();

    NoOpResponseParser responseParser = new NoOpResponseParser();
    responseParser.setWriterType("json");

    cloudSolrClient.setParser(responseParser);

    CollectionAdminRequest collectionAdminRequest = new CollectionAdminRequest.ClusterStatus();

    NamedList<Object> collectionAdminResponse = cloudSolrClient.request(collectionAdminRequest);

    List<JsonNode> baseUrlJsonNode = om.readTree((String) collectionAdminResponse.get("response")).findValues("base_url");

    for (Iterator<JsonNode> i = baseUrlJsonNode.iterator(); i.hasNext(); ) {
        String baseUrl = i.next().textValue();
        if (!baseUrls.contains(baseUrl)) {
            baseUrls.add(baseUrl);
        }
    }

    return baseUrls;
}
 
开发者ID:mosuka,项目名称:solr-exporter,代码行数:30,代码来源:SolrCollector.java

示例9: 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;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRSolrProxyServlet.java

示例10: index

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
public void index() throws IOException, SolrServerException {
    long tStart = System.currentTimeMillis();
    ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(UPDATE_PATH);
    updateRequest.addContentStream(getStream());
    if (STYLESHEET.length() > 0) {
        updateRequest.setParam("tr", STYLESHEET);
    }
    updateRequest.setCommitWithin(getCommitWithin());
    NamedList<Object> request = getSolrClient().request(updateRequest);
    if (LOGGER.isDebugEnabled()) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Solr: indexing data of \"");
        stringBuilder.append(this);
        stringBuilder.append("\" (");
        stringBuilder.append((System.currentTimeMillis() - tStart));
        stringBuilder.append("ms)");
        for (Map.Entry<String, Object> entry : request) {
            stringBuilder.append('\n');
            stringBuilder.append(entry.getKey());
            stringBuilder.append('=');
            stringBuilder.append(entry.getValue());
        }
        LOGGER.debug(stringBuilder.toString());
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:26,代码来源:MCRSolrObjectStreamIndexHandler.java

示例11: isRatioAcceptable

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
public boolean isRatioAcceptable(NamedList<Object> sug, long originalQueryHits, int spellcheckCount) {
  float ratio = calculateRatio(sug, spellcheckCount);
  float ratioToCheck = 0.0f;
  
  if (originalQueryHits == 0) {
    ratioToCheck = minRequiredSuggestionRatioForZeroHits;
  }
  else {
    ratioToCheck = minRequiredSuggestionRatio;
  }
  
  if (ratio >= ratioToCheck) {
    return true;
  }
  
  return false;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:18,代码来源:SuggestionsFoundRatioCalculator.java

示例12: process

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
@Override
public void process(NamedList<Object> wordData, String wordName) {
  if (ratioCalculator.isRatioAcceptable(wordData, originalQueryHits, spellcheckCount)) {
    float thisRatio = SuggestionsFoundRatioCalculator.calculateRatio(wordData, spellcheckCount);
    // System.out.println("Suggestion, ratio :" + suggestions.getName(i) + ", " + thisRatio);
    
    if (thisRatio > highestRatio) {
      highestRatio = thisRatio;
      misspellingWithHighestRatio = wordName;
    }

    if (misspelling == null) {
      if (originalQueryHits == 0 && thisRatio >= ratioCalculator.getMinRequiredSuggestionRatioForZeroHits()) {
        // we want to remember just the first misspelling, but also loop through all possible suggestions
        misspelling = wordName;
      }
      else if (originalQueryHits > 0 && thisRatio >= ratioCalculator.getMinRequiredSuggestionRatio()) {
        // we want to remember just the first misspelling, but also loop through all possible suggestions
        misspelling = wordName;
      }
    }

    countOfMisspellings++;
  }
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:26,代码来源:FindMisspelingProcessor.java

示例13: process

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
@Override
public void process(NamedList<Object> wordData, String wordName) {
  if (stopIterating) {
    return;
  }
  
  if (ratioCalculator.isRatioAcceptable(wordData, originalQueryHits, spellcheckCount)) {
    if (highestRatio != null) {
      // if we have it, use highestRatio criterion
      if (SuggestionsFoundRatioCalculator.calculateRatio(wordData, spellcheckCount) >= highestRatio.floatValue()) {
        suggestionWithHighestRatio = wordData;
        stopIterating = true;
        return;
      }
      else {
      }
    }
    else {
      suggestionWithHighestRatio = wordData;
      stopIterating = true;
      return;
    }
  }
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:25,代码来源:SuggestionRatioProcessor.java

示例14: init

import org.apache.solr.common.util.NamedList; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void init(NamedList args) {
  maxOriginalResults = getInt(args, "maxOriginalResults");
  String tmp = (String) args.get("allComponentNames");
  if (tmp != null) {
    componentNames.addAll(Arrays.asList(tmp.split("\\s*,\\s*")));
  }
  componentNames.add(getComponentName());
  componentNames.add(FacetComponent.COMPONENT_NAME);
  componentNames.add(HighlightComponent.COMPONENT_NAME);
  componentNames.add(StatsComponent.COMPONENT_NAME);
  componentNames.add(TermsComponent.COMPONENT_NAME);
  componentNames.add(TermVectorComponent.COMPONENT_NAME);
  componentNames.add(SpellCheckComponent.COMPONENT_NAME);
  componentNames.add(MoreLikeThisComponent.COMPONENT_NAME);
  componentNames.add(GroupParams.GROUP);
  componentNames.add("queryRelaxer");
  componentNames.add("DymReSearcher");
  componentNames.add("autoComplete");
  commonMisspellingsFileLocation = (String) args.get("commonMisspellingsFile");
  commonMisspellingsMap = CommonMisspellings.loadCommonMisspellingsFile(commonMisspellingsFileLocation);
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:24,代码来源:AbstractReSearcherComponent.java

示例15: 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;
        }
    }
}
 
开发者ID:redlink-gmbh,项目名称:solrj-text-tagger,代码行数:20,代码来源:TagResponse.java


注:本文中的org.apache.solr.common.util.NamedList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。