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


Java NamedList.add方法代码示例

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


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

示例1: 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

示例2: init

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Before
public void init()
{

    new MockUp<SolrQueryResponse>()
    {
        @Mock public NamedList<Object> getResponseHeader()
        {
            NamedList<Object> headers = new NamedList<>();
            headers.add("status", 400);
            return headers;
        }
    };
    request = new LocalSolrQueryRequest(null, dummy);
    response = new SolrQueryResponse();
    response.setHttpHeader("status", "400");
}
 
开发者ID:careerbuilder,项目名称:semantic-knowledge-graph,代码行数:18,代码来源:KnowledgeGraphResponseWriterTest.java

示例3: addEntry

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public void addEntry(LimitMinder<T, SimpleTermIndexKey> limitMinder, SimpleTermIndexKey facetKey, Deque<Entry<String, Object>> entryBuilder) throws IOException {
  ShardFacetCount sfc = counts[facetKey.index];
  TermDocEntry val = (TermDocEntry)sfc.val;
  String currentTerm = val.term;
  String docIdStr = val.docId;
  SolrDocument doc = val.doc;
  if (!limitMinder.updateEntry(currentTerm, docIdStr, doc, entryBuilder)) {
    Deque<Entry<String, SolrDocument>> docDeque = new ArrayDeque<>(4);
    docDeque.add(new SimpleImmutableEntry<>(docIdStr, doc));
    NamedList<Object> termEntry = new NamedList<>(2);
    if (val.termMetadata != null) {
      termEntry.add("termMetadata", val.termMetadata);
    }
    termEntry.add("docs", docDeque);
    Entry<String, Object> entry = new SimpleImmutableEntry<>(currentTerm, termEntry);
    limitMinder.addEntry(entry, entryBuilder);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:20,代码来源:BidirectionalFacetResponseBuilder.java

示例4: getHeatmapCounts

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
  if (unparsedFields == null || unparsedFields.length == 0) {
    return resOuter;
  }
  if (global.getBool(GroupParams.GROUP_FACET, false)) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
        "Heatmaps can't be used with " + GroupParams.GROUP_FACET);
  }
  for (String unparsedField : unparsedFields) {
    final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs

    resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
  }
  return resOuter;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:18,代码来源:SimpleFacets.java

示例5: toFilteredSolrParams

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/** Create filtered SolrParams. */
public SolrParams toFilteredSolrParams(List<String> names) {
    NamedList<String> nl = new NamedList<>();
    for (Iterator<String> it = getParameterNamesIterator(); it.hasNext();) {
        final String name = it.next();
        if (names.contains(name)) {
            final String[] values = getParams(name);
            for (String value : values) {
                nl.add(name, value);
            }
        }
    }
    return toSolrParams(nl);
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:15,代码来源:SolrParams.java

示例6: write

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public Object write() {
    Map<String,Object> suggestion_result = new HashMap<String, Object>();

    //sort results
    Collections.sort(suggestion_list,new Comparator<MultiFacet>() {
        @Override
        public int compare(MultiFacet multiFacet, MultiFacet multiFacet2) {
            return Integer.valueOf(multiFacet2.count).compareTo(multiFacet.count);
        }
    });

    //Crop results
    //TODO use limitType
    if(limit < Integer.MAX_VALUE && limit < suggestion_list.size()) {
        suggestion_list = suggestion_list.subList(0,limit);
    }

    suggestion_result.put(SuggestionResultParams.SUGGESTION_COUNT, suggestion_list.size());

    NamedList suggestions = new NamedList();

    for(MultiFacet mf : suggestion_list) {
        suggestions.add(mf.name.toLowerCase(), mf.write());
    }

    suggestion_result.put(SuggestionResultParams.SUGGESTION_FACETS,suggestions);
    return suggestion_result;
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:30,代码来源:SuggestionResultMulti.java

示例7: process

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
 * Here we define the component core logic.
 * For each document belonging to search results, we call an external service
 * for gathering a corresponding up-to-date price.
 * 
 * @param rb The {@link org.apache.solr.handler.component.ResponseBuilder}
 * @throws IOException If there is a low-level I/O error.
 */
@Override
public void process(final ResponseBuilder builder) throws IOException {
	// Sanity check: if the component hasn't been properly initialised 
	// then it must immediately return.
	// A more ideal approach could retry the initialisation (in the prepare method).
	if (!hasBeenCorrectlyInitialised) {
		return;
	}
	
	// Get a SolrIndexSearcher reference 
	final SolrIndexSearcher searcher = builder.req.getSearcher();

	// This NamediLis will hold the component contribution (i.e. the component result).
	final NamedList<Double> contribution = new SimpleOrderedMap<Double>();
	for (final DocIterator it = builder.getResults().docList.iterator(); it.hasNext();) {

		// This is NOT the Solr ID of our records, but instead the Lucene internal document id
		// which is different
		int docId = it.nextDoc();
		final Document luceneDocument = searcher.doc(docId);
		
		// This is the Solr document Id 
		String id = luceneDocument.get("id");

		// Get the price of the item
		final Double itemPrice = getPrice(id);

		// Add the price of the item to the component contribution
		contribution.add(id, itemPrice);
	}

	// Add the component contribution to the response builder
	builder.rsp.add("prices", contribution);			
}
 
开发者ID:agazzarini,项目名称:as-full-text-search-server,代码行数:43,代码来源:CustomSearchComponent.java

示例8: request

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) {
  SolrCore core = h.getCore();
  SolrRequestHandler handler = core.getRequestHandler(handlerName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  NamedList<Object> list = new NamedList<Object>();
  list.add("responseHeader", new SimpleOrderedMap<Object>());
  rsp.setAllValues(list);
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  return req;
}
 
开发者ID:sematext,项目名称:query-segmenter,代码行数:13,代码来源:QuerySegmenterQParserTest.java

示例9: getStatistics

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Override
public NamedList<Object> getStatistics() {
    // Change stats here to get an insight in the admin console.
    NamedList<Object> statistics = super.getStatistics();
    statistics.add("Number of Requests", countRequests);
    return statistics;
}
 
开发者ID:dermotte,项目名称:liresolr,代码行数:8,代码来源:LireRequestHandler.java

示例10: solrIsUp

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
@Test
public void solrIsUp() throws Exception {
	SolrClient solrClient = mock(SolrClient.class);
	SolrPingResponse pingResponse = new SolrPingResponse();
	NamedList<Object> response = new NamedList<Object>();
	response.add("status", "OK");
	pingResponse.setResponse(response);
	given(solrClient.ping()).willReturn(pingResponse);
	SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
	Health health = healthIndicator.health();
	assertThat(health.getStatus()).isEqualTo(Status.UP);
	assertThat(health.getDetails().get("solrStatus")).isEqualTo("OK");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:SolrHealthIndicatorTests.java

示例11: getAndPrepShardHandler

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
private ShardHandler getAndPrepShardHandler(SolrQueryRequest req, ResponseBuilder rb, ShardHandlerFactory shardHandlerFactory) {
  ShardHandler shardHandler = null;

  boolean isZkAware = false;
  CoreContainer cc = null;
  if (req.getCore() != null) {
    cc = req.getCore().getCoreContainer();
    isZkAware = cc.isZooKeeperAware();
  } 
  
  rb.isDistrib = req.getParams().getBool("distrib", isZkAware);
  if (!rb.isDistrib) {
    // for back compat, a shards param with URLs like localhost:8983/solr will mean that this
    // search is distributed.
    final String shards = req.getParams().get(ShardParams.SHARDS);
    rb.isDistrib = ((shards != null) && (shards.indexOf('/') > 0));
  }
  
  if (rb.isDistrib) {
    shardHandler = shardHandlerFactory.getShardHandler();
    shardHandler.prepDistributed(rb);
    if (!rb.isDistrib) {
      shardHandler = null; // request is not distributed after all and so the shard handler is not needed
    }
  }

  if(isZkAware) {
    ZkController zkController = cc.getZkController();
    NamedList<Object> headers = rb.rsp.getResponseHeader();
    if(headers != null) {
      headers.add("zkConnected", 
          zkController != null 
        ? !zkController.getZkClient().getConnectionManager().isLikelyExpired() 
        : false);
    }
    
  }

  return shardHandler;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:41,代码来源:ReSearcherHandler.java

示例12: overwriteInNamedList

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
 * overwrite entry in NamedList with new value
 * (update existing key, or add the key/value if key doesn't already exist)
 */
private static void overwriteInNamedList(NamedList<Object> namedList, String key, Object value) {
  int indexOfKey = namedList.indexOf(key, 0);
  if(indexOfKey != -1) {
    namedList.setVal(indexOfKey, value);
  } else {
    namedList.add(key, value);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:13,代码来源:JsonReferencePayloadHandler.java

示例13: copyFieldInNamedList

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
 * Copies a field value from one NamedList into another
 */
private static void copyFieldInNamedList(NamedList<Object> from, NamedList<Object> to, String key) {
  int index = from.indexOf(key, 0);
  if(index != -1) {
    Object value = from.get(key);
    int index2 = to.indexOf(key, 0);
    if(index2 != -1) {
      to.setVal(index2, value);
    } else {
      to.add(key, value);
    }
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:16,代码来源:JsonReferencePayloadHandler.java

示例14: getOrCreateNamedListValue

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
 * For passed-in NamedList, get the NamedList value for a certain key,
 * creating and storing it if it doesn't exist.
 * @param namedList
 * @param key
 */
private static NamedList<Object> getOrCreateNamedListValue(NamedList<Object> namedList, String key) {
  NamedList<Object> result = (NamedList<Object>) namedList.get(key);
  if(result == null) {
    result = new NamedList<>();
    namedList.add(key, result);
  }
  return result;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:15,代码来源:JsonReferencePayloadHandler.java

示例15: incrementLongInNamedList

import org.apache.solr.common.util.NamedList; //导入方法依赖的package包/类
/**
 * increment a Long value in a NamedList stored under "key", creating it with value of 1
 * if it doesn't exist.
 */
private static void incrementLongInNamedList(NamedList<Object> namedList, String key) {
  int index = namedList.indexOf(key, 0);
  if(index != -1) {
    long oldCount = ((Number) namedList.getVal(index)).longValue();
    namedList.setVal(index, oldCount + 1L);
  } else {
    namedList.add(key, 1L);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:14,代码来源:JsonReferencePayloadHandler.java


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