Package org.apache.solr.common

Examples of org.apache.solr.common.SolrDocumentList


      // multi sharded request
      String[] shards = shardsVal.split(",");
      res = DispatchUtil.broadcast(_threadPool, solrParams, br, shards, 5);
    }
     
      SolrDocumentList docList = new SolrDocumentList();
     
     
      docList.setNumFound(res.getNumHits());
      docList.setStart(br.getOffset());
     
      rb.stage = ResponseBuilder.STAGE_GET_FIELDS;
      boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
     
      BrowseHit[] hits = res.getHits();
      if (hits!=null){
        for (BrowseHit hit : hits){
        SolrDocument doc = convert(hit,rb.rsp.getReturnFields());
        if (doc!=null){
          if (returnScores){
            doc.addField("score", hit.getScore());
          }
          docList.add(doc);
        }
        }
      }
     
      rb.rsp.add("response", docList);
View Full Code Here


     * to get all results set the query String to "*:*"
     * @param querystring
     * @throws IOException
     */
    public SolrDocumentList get(final String querystring, final int offset, final int count) throws IOException {
        final SolrDocumentList list = new SolrDocumentList();
        for (final SolrSingleConnector connector: this.connectors) {
            final SolrDocumentList l = connector.get(querystring, offset, count);
            for (final SolrDocument d: l) {
                list.add(d);
            }
        }
        return list;
View Full Code Here

    public long[] getSizeList() {
        final long[] size = new long[this.connectors.size()];
        int i = 0;
        for (final SolrSingleConnector connector: this.connectors) {
            try {
                final SolrDocumentList list = connector.get("*:*", 0, 1);
                size[i++] = list.getNumFound();
            } catch (final Exception e) {
                Log.logException(e);
                size[i++] = 0;
            }
        }
View Full Code Here

        // query the server
        //SearchResult result = new SearchResult(count);
        try {
            final QueryResponse rsp = this.server.query( query );
            final SolrDocumentList docs = rsp.getResults();
            return docs;
            // add the docs into the YaCy search result container
            /*
            for (SolrDocument doc: docs) {
                result.put(element)
View Full Code Here

    SolrQuery query = new SolrQuery();
    query.setQuery( descriptor + ":" + identifier );
    query.addField("FgdcText");
    query.setRows(1);
   
     SolrDocumentList docs = this.solrClient.getSolrServer().query(query).getResults();
     return (String) docs.get(0).getFieldValue("FgdcText");
  }
View Full Code Here

    }
    return doc;
  }

  public SolrDocumentList readSolrDocumentList(FastInputStream dis) throws IOException {
    SolrDocumentList solrDocs = new SolrDocumentList();
    List list = (List) readVal(dis);
    solrDocs.setNumFound((Long) list.get(0));
    solrDocs.setStart((Long) list.get(1));
    solrDocs.setMaxScore((Float) list.get(2));
    solrDocs.setSum((Double) list.get(3));
    solrDocs.setMax((Double) list.get(4));
    solrDocs.setMin((Double) list.get(5));
    List l = (List) readVal(dis);
    solrDocs.addAll(l);
    return solrDocs;
  }
View Full Code Here

      query.setQuery("units_i:2");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), docCount / 10);
      for (int i = 0; i < results.size(); i++) {
        SolrDocument doc = results.get(i);

        int docId = (i * 10) + 2;
        Assert.assertEquals(doc.get("id"), String.valueOf(docId));
        Assert.assertEquals(doc.get("units_i"), 2);
        Assert.assertEquals(doc.get("name_t"), "document" + docId);
View Full Code Here

      query.setQuery("value_i:[* TO 9]");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), 10);
      for (int i = 0; i < results.size(); i++) {
        SolrDocument doc = results.get(i);

        int docId = i;
        Assert.assertEquals(doc.get("id"), String.valueOf(docId));
        Assert.assertEquals(doc.get("value_i"), docId);
        Assert.assertEquals(doc.get(field), fieldValues.get(i));
View Full Code Here

        NamedList<Object> command = new SimpleOrderedMap<Object>();
        command.add("matches", topGroups.totalHitCount);
        if (topGroups.totalGroupCount != null) {
          command.add("ngroups", topGroups.totalGroupCount);
        }
        SolrDocumentList docList = new SolrDocumentList();
        docList.setStart(groupingSpecification.getOffset());
        docList.setNumFound(topGroups.totalHitCount);

        Float maxScore = Float.NEGATIVE_INFINITY;
        for (GroupDocs<BytesRef> group : topGroups.groups) {
          for (ScoreDoc scoreDoc : group.scoreDocs) {
            if (maxScore < scoreDoc.score) {
              maxScore = scoreDoc.score;
            }
            docList.add(solrDocumentSource.retrieve(scoreDoc));
          }
        }
        if (maxScore != Float.NEGATIVE_INFINITY) {
          docList.setMaxScore(maxScore);
        }
        command.add("doclist", docList);
        commands.add(entry.getKey(), command);
      }
    }
View Full Code Here

  public void transform(Map<String, ?> result, SolrQueryResponse response, GroupingSpecification groupingSpecification, SolrDocumentSource solrDocumentSource) {
    Object value = result.get(groupingSpecification.getFields()[0]);
    if (TopGroups.class.isInstance(value)) {
      @SuppressWarnings("unchecked")
      TopGroups<BytesRef> topGroups = (TopGroups<BytesRef>) value;
      SolrDocumentList docList = new SolrDocumentList();
      docList.setStart(groupingSpecification.getOffset());
      docList.setNumFound(topGroups.totalHitCount);

      Float maxScore = Float.NEGATIVE_INFINITY;
      for (GroupDocs<BytesRef> group : topGroups.groups) {
        for (ScoreDoc scoreDoc : group.scoreDocs) {
          if (maxScore < scoreDoc.score) {
            maxScore = scoreDoc.score;
          }
          docList.add(solrDocumentSource.retrieve(scoreDoc));
        }
      }
      if (maxScore != Float.NEGATIVE_INFINITY) {
        docList.setMaxScore(maxScore);
      }
      response.add("response", docList);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.common.SolrDocumentList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.