Java Code Examples for org.apache.solr.common.SolrDocumentList#iterator()
The following examples show how to use
org.apache.solr.common.SolrDocumentList#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Application.java From tools-journey with Apache License 2.0 | 6 votes |
@Override public void run(String... strings) throws IOException, SolrServerException { Product phone = new Product(); phone.setId("P0002"); phone.setName("Phone"); productRepository.save(phone); System.out.println(productRepository.findOne("P0001")); System.out.println(productRepository.findById("P0001")); SolrDocumentList list = client.getById("product", Lists.newArrayList("P0001", "P0002")); Iterator<SolrDocument> iterator = list.iterator(); while (iterator.hasNext()) { SolrDocument entry = iterator.next(); System.out.println(entry.entrySet()); } }
Example 2
Source File: SearchStream.java From lucene-solr with Apache License 2.0 | 6 votes |
public void open() throws IOException { if(cache != null) { cloudSolrClient = cache.getCloudSolrClient(zkHost); } else { final List<String> hosts = new ArrayList<>(); hosts.add(zkHost); cloudSolrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).build(); } QueryRequest request = new QueryRequest(params, SolrRequest.METHOD.POST); try { QueryResponse response = request.process(cloudSolrClient, collection); SolrDocumentList docs = response.getResults(); documentIterator = docs.iterator(); } catch (Exception e) { throw new IOException(e); } }
Example 3
Source File: TestBaseStatsCache.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override protected void checkResponse(QueryResponse controlRsp, QueryResponse shardRsp) { System.out.println("======================= Control Response ======================="); System.out.println(controlRsp); System.out.println(""); System.out.println(""); System.out.println("======================= Shard Response ======================="); System.out.println(""); System.out.println(shardRsp); SolrDocumentList shardList = shardRsp.getResults(); SolrDocumentList controlList = controlRsp.getResults(); assertEquals(controlList.size(), shardList.size()); assertEquals(controlList.getNumFound(), shardList.getNumFound()); Iterator<SolrDocument> it = controlList.iterator(); Iterator<SolrDocument> it2 = shardList.iterator(); while (it.hasNext()) { SolrDocument controlDoc = it.next(); SolrDocument shardDoc = it2.next(); assertEquals(controlDoc.getFieldValue("score"), shardDoc.getFieldValue("score")); } }
Example 4
Source File: KnnStream.java From lucene-solr with Apache License 2.0 | 5 votes |
public void open() throws IOException { cloudSolrClient = cache.getCloudSolrClient(zkHost); ModifiableSolrParams params = getParams(this.props); StringBuilder builder = new StringBuilder(); for(String key : mltParams) { if(params.get(key) != null) { builder.append(' ').append(key).append('=').append(params.get(key)); params.remove(key); } } String k = params.get("k"); if(k != null) { params.add(ROWS, k); params.remove(k); } params.add(Q, "{!mlt"+builder.toString()+"}"+id); QueryRequest request = new QueryRequest(params); try { QueryResponse response = request.process(cloudSolrClient, collection); SolrDocumentList docs = response.getResults(); documentIterator = docs.iterator(); } catch (Exception e) { throw new IOException(e); } }
Example 5
Source File: RandomStream.java From lucene-solr with Apache License 2.0 | 5 votes |
public void open() throws IOException { if(cache != null) { cloudSolrClient = cache.getCloudSolrClient(zkHost); } else { final List<String> hosts = new ArrayList<>(); hosts.add(zkHost); cloudSolrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).withSocketTimeout(30000).withConnectionTimeout(15000).build(); } ModifiableSolrParams params = getParams(this.props); params.remove(SORT); //Override any sort. Random rand = new Random(); int seed = rand.nextInt(); String sortField = "random_"+seed; params.add(SORT, sortField+" asc"); QueryRequest request = new QueryRequest(params, SolrRequest.METHOD.POST); try { QueryResponse response = request.process(cloudSolrClient, collection); SolrDocumentList docs = response.getResults(); documentIterator = docs.iterator(); } catch (Exception e) { throw new IOException(e); } }
Example 6
Source File: SolrEntityProcessor.java From lucene-solr with Apache License 2.0 | 5 votes |
public SolrDocumentListIterator(SolrDocumentList solrDocumentList) { this.solrDocumentIterator = solrDocumentList.iterator(); this.numFound = solrDocumentList.getNumFound(); // SolrQuery has the start field of type int while SolrDocumentList of // type long. We are always querying with an int so we can't receive a // long as output. That's the reason why the following cast seems safe this.start = (int) solrDocumentList.getStart(); this.size = solrDocumentList.size(); }