Package org.apache.solr.handler.component

Examples of org.apache.solr.handler.component.ShardDoc


    SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
    String uniqueIdFieldName = rb.req.getSchema().getUniqueKeyField().getName();

    for (SolrDocument doc : docs) {
      Object id = doc.getFieldValue(uniqueIdFieldName).toString();
      ShardDoc shardDoc = rb.resultIds.get(id);
      FieldDoc fieldDoc = (FieldDoc) shardDoc;
      if (shardDoc != null) {
        if (returnScores && !Float.isNaN(fieldDoc.score)) {
            doc.setField("score", fieldDoc.score);
        }
View Full Code Here


      Map<Object, ShardDoc> resultIds = new HashMap<Object, ShardDoc>();
      int i = 0;
      for (TopGroups<String> topGroups : rb.mergedTopGroups.values()) {
        for (GroupDocs<String> group : topGroups.groups) {
          for (ScoreDoc scoreDoc : group.scoreDocs) {
            ShardDoc solrDoc = (ShardDoc) scoreDoc;
            solrDoc.positionInResponse = i++;
            resultIds.put(solrDoc.id, solrDoc);
          }
        }
      }
      for (QueryCommandResult queryCommandResult : rb.mergedQueryCommandResults.values()) {
        for (ScoreDoc scoreDoc : queryCommandResult.getTopDocs().scoreDocs) {
          ShardDoc solrDoc = (ShardDoc) scoreDoc;
          solrDoc.positionInResponse = i++;
          resultIds.put(solrDoc.id, solrDoc);
        }
      }
View Full Code Here

    return shardRequests;
  }

  private void mapShardToDocs(HashMap<String, Set<ShardDoc>> shardMap, ScoreDoc[] scoreDocs) {
    for (ScoreDoc scoreDoc : scoreDocs) {
      ShardDoc solrDoc = (ShardDoc) scoreDoc;
      Set<ShardDoc> shardDocs = shardMap.get(solrDoc.shard);
      if (shardDocs == null) {
        shardMap.put(solrDoc.shard, shardDocs = new HashSet<ShardDoc>());
      }
      shardDocs.add(solrDoc);
View Full Code Here

          Float score = (Float) document.get("score");
          if (score == null) {
            score = Float.NaN;
          }
          Object[] sortValues = ((List) document.get("sortValues")).toArray();
          scoreDocs[j++] = new ShardDoc(score, sortValues, uniqueId, shard);
        }
        result.put(key, new QueryCommandResult(new TopDocs(totalHits, scoreDocs, maxScore, sum, max, min), matches));
        continue;
      }

      Integer totalHitCount = (Integer) commandResult.get("totalHitCount");
      Integer totalGroupCount = (Integer) commandResult.get("totalGroupCount");

      List<GroupDocs<String>> groupDocs = new ArrayList<GroupDocs<String>>();
      for (int i = totalGroupCount == null ? 2 : 3; i < commandResult.size(); i++) {
        String groupValue = commandResult.getName(i);
        @SuppressWarnings("unchecked")
        NamedList<Object> groupResult = (NamedList<Object>) commandResult.getVal(i);
        Integer totalGroupHits = (Integer) groupResult.get("totalHits");
        Float maxScore = (Float) groupResult.get("maxScore");
        if (maxScore == null) {
          maxScore = Float.NaN;
        }
    Double sum = (Double) groupResult.get("sum");
    Double max = (Double) groupResult.get("max");
        Double min = (Double) groupResult.get("min");
        if (sum == null) { sum = Double.valueOf(0.0f); }
        if (max == null) { max = Double.NEGATIVE_INFINITY; }
        if (min == null) { min = Double.POSITIVE_INFINITY; }

        @SuppressWarnings("unchecked")
        List<NamedList<Object>> documents = (List<NamedList<Object>>) groupResult.get("documents");
        ScoreDoc[] scoreDocs = new ScoreDoc[documents.size()];
        int j = 0;
        for (NamedList<Object> document : documents) {
          Object uniqueId = document.get("id").toString();
          Float score = (Float) document.get("score");
          if (score == null) {
            score = Float.NaN;
          }
          //System.out.println("######### transformToNative:"+document.get("sortValues"));
          List sortValuesList = (List) document.get("sortValues");
          Object[] sortValues = sortValuesList==null?new Object[0]:sortValuesList.toArray();
          scoreDocs[j++] = new ShardDoc(score, sortValues, uniqueId, shard);
        }

        String groupValueRef = groupValue != null ? groupValue : null;
        groupDocs.add(new GroupDocs<String>(maxScore, totalGroupHits, scoreDocs, groupValueRef, null, sum, max, min));
      }
View Full Code Here

TOP

Related Classes of org.apache.solr.handler.component.ShardDoc

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.