示例#1
0
  public static TopDocs readTopDocs(StreamInput in) throws IOException {
    if (!in.readBoolean()) {
      // no docs
      return null;
    }
    if (in.readBoolean()) {
      int totalHits = in.readVInt();
      float maxScore = in.readFloat();

      SortField[] fields = new SortField[in.readVInt()];
      for (int i = 0; i < fields.length; i++) {
        String field = null;
        if (in.readBoolean()) {
          field = in.readUTF();
        }
        fields[i] = new SortField(field, in.readVInt(), in.readBoolean());
      }

      FieldDoc[] fieldDocs = new FieldDoc[in.readVInt()];
      for (int i = 0; i < fieldDocs.length; i++) {
        Comparable[] cFields = new Comparable[in.readVInt()];
        for (int j = 0; j < cFields.length; j++) {
          byte type = in.readByte();
          if (type == 0) {
            cFields[j] = null;
          } else if (type == 1) {
            cFields[j] = in.readUTF();
          } else if (type == 2) {
            cFields[j] = in.readInt();
          } else if (type == 3) {
            cFields[j] = in.readLong();
          } else if (type == 4) {
            cFields[j] = in.readFloat();
          } else if (type == 5) {
            cFields[j] = in.readDouble();
          } else if (type == 6) {
            cFields[j] = in.readByte();
          } else if (type == 7) {
            cFields[j] = in.readShort();
          } else if (type == 8) {
            cFields[j] = in.readBoolean();
          } else {
            throw new IOException("Can't match type [" + type + "]");
          }
        }
        fieldDocs[i] = new FieldDoc(in.readVInt(), in.readFloat(), cFields);
      }
      return new TopFieldDocs(totalHits, fieldDocs, fields, maxScore);
    } else {
      int totalHits = in.readVInt();
      float maxScore = in.readFloat();

      ScoreDoc[] scoreDocs = new ScoreDoc[in.readVInt()];
      for (int i = 0; i < scoreDocs.length; i++) {
        scoreDocs[i] = new ScoreDoc(in.readVInt(), in.readFloat());
      }
      return new TopDocs(totalHits, scoreDocs, maxScore);
    }
  }
 /** Read from a stream. */
 TermSuggestionBuilder(StreamInput in) throws IOException {
   super(in);
   suggestMode = SuggestMode.readFromStream(in);
   accuracy = in.readFloat();
   sort = SortBy.readFromStream(in);
   stringDistance = StringDistanceImpl.readFromStream(in);
   maxEdits = in.readVInt();
   maxInspections = in.readVInt();
   maxTermFreq = in.readFloat();
   prefixLength = in.readVInt();
   minWordLength = in.readVInt();
   minDocFreq = in.readFloat();
 }
 @Override
 protected DisMaxQueryBuilder doReadFrom(StreamInput in) throws IOException {
   DisMaxQueryBuilder disMax = new DisMaxQueryBuilder();
   List<QueryBuilder> queryBuilders = readQueries(in);
   disMax.queries.addAll(queryBuilders);
   disMax.tieBreaker = in.readFloat();
   return disMax;
 }
示例#4
0
 public static Explanation readExplanation(StreamInput in) throws IOException {
   float value = in.readFloat();
   String description = in.readString();
   Explanation explanation = new Explanation(value, description);
   if (in.readBoolean()) {
     int size = in.readVInt();
     for (int i = 0; i < size; i++) {
       explanation.addDetail(readExplanation(in));
     }
   }
   return explanation;
 }
 @Override
 protected CommonTermsQueryBuilder doReadFrom(StreamInput in) throws IOException {
   CommonTermsQueryBuilder commonTermsQueryBuilder =
       new CommonTermsQueryBuilder(in.readString(), in.readGenericValue());
   commonTermsQueryBuilder.highFreqOperator = Operator.readOperatorFrom(in);
   commonTermsQueryBuilder.lowFreqOperator = Operator.readOperatorFrom(in);
   commonTermsQueryBuilder.analyzer = in.readOptionalString();
   commonTermsQueryBuilder.lowFreqMinimumShouldMatch = in.readOptionalString();
   commonTermsQueryBuilder.highFreqMinimumShouldMatch = in.readOptionalString();
   commonTermsQueryBuilder.disableCoord = in.readBoolean();
   commonTermsQueryBuilder.cutoffFrequency = in.readFloat();
   return commonTermsQueryBuilder;
 }
示例#6
0
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    minScore = in.readFloat();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    sourceUnsafe = false;
    source = in.readBytesReference();
    types = in.readStringArray();

    if (in.getVersion().onOrAfter(Version.V_1_4_0_Beta1)) {
      terminateAfter = in.readVInt();
    }
  }
 @Override
 protected SimpleQueryStringBuilder doReadFrom(StreamInput in) throws IOException {
   SimpleQueryStringBuilder result = new SimpleQueryStringBuilder(in.readString());
   int size = in.readInt();
   Map<String, Float> fields = new HashMap<>();
   for (int i = 0; i < size; i++) {
     String field = in.readString();
     Float weight = in.readFloat();
     fields.put(field, weight);
   }
   result.fieldsAndWeights.putAll(fields);
   result.flags = in.readInt();
   result.analyzer = in.readOptionalString();
   result.defaultOperator = Operator.readOperatorFrom(in);
   result.settings.lowercaseExpandedTerms(in.readBoolean());
   result.settings.lenient(in.readBoolean());
   result.settings.analyzeWildcard(in.readBoolean());
   String localeStr = in.readString();
   result.settings.locale(Locale.forLanguageTag(localeStr));
   result.minimumShouldMatch = in.readOptionalString();
   return result;
 }
 @Override
 protected MatchQueryBuilder doReadFrom(StreamInput in) throws IOException {
   MatchQueryBuilder matchQuery = new MatchQueryBuilder(in.readString(), in.readGenericValue());
   matchQuery.type = MatchQuery.Type.readTypeFrom(in);
   matchQuery.operator = Operator.readOperatorFrom(in);
   matchQuery.slop = in.readVInt();
   matchQuery.prefixLength = in.readVInt();
   matchQuery.maxExpansions = in.readVInt();
   matchQuery.fuzzyTranspositions = in.readBoolean();
   matchQuery.lenient = in.readBoolean();
   matchQuery.zeroTermsQuery = MatchQuery.ZeroTermsQuery.readZeroTermsQueryFrom(in);
   // optional fields
   matchQuery.analyzer = in.readOptionalString();
   matchQuery.minimumShouldMatch = in.readOptionalString();
   matchQuery.fuzzyRewrite = in.readOptionalString();
   if (in.readBoolean()) {
     matchQuery.fuzziness = Fuzziness.readFuzzinessFrom(in);
   }
   if (in.readBoolean()) {
     matchQuery.cutoffFrequency = in.readFloat();
   }
   return matchQuery;
 }
  @Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    minScore = in.readFloat();

    querySource = in.readBytesReference();

    int typesSize = in.readVInt();
    if (typesSize > 0) {
      types = new String[typesSize];
      for (int i = 0; i < typesSize; i++) {
        types[i] = in.readString();
      }
    }
    int aliasesSize = in.readVInt();
    if (aliasesSize > 0) {
      filteringAliases = new String[aliasesSize];
      for (int i = 0; i < aliasesSize; i++) {
        filteringAliases[i] = in.readString();
      }
    }
    nowInMillis = in.readVLong();
  }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   percolatorTypeId = in.readByte();
   requestedSize = in.readVInt();
   count = in.readVLong();
   matches = new BytesRef[in.readVInt()];
   for (int i = 0; i < matches.length; i++) {
     matches[i] = in.readBytesRef();
   }
   scores = new float[in.readVInt()];
   for (int i = 0; i < scores.length; i++) {
     scores[i] = in.readFloat();
   }
   int size = in.readVInt();
   for (int i = 0; i < size; i++) {
     int mSize = in.readVInt();
     Map<String, HighlightField> fields = new HashMap<>();
     for (int j = 0; j < mSize; j++) {
       fields.put(in.readString(), HighlightField.readHighlightField(in));
     }
     hls.add(fields);
   }
   aggregations = InternalAggregations.readOptionalAggregations(in);
   if (in.readBoolean()) {
     int pipelineAggregatorsSize = in.readVInt();
     List<SiblingPipelineAggregator> pipelineAggregators =
         new ArrayList<>(pipelineAggregatorsSize);
     for (int i = 0; i < pipelineAggregatorsSize; i++) {
       BytesReference type = in.readBytesReference();
       PipelineAggregator pipelineAggregator =
           PipelineAggregatorStreams.stream(type).readResult(in);
       pipelineAggregators.add((SiblingPipelineAggregator) pipelineAggregator);
     }
     this.pipelineAggregators = pipelineAggregators;
   }
 }
 public void testSimpleStreams() throws Exception {
   assumeTrue("requires a 64-bit JRE ... ?!", Constants.JRE_IS_64BIT);
   BytesStreamOutput out = new BytesStreamOutput();
   out.writeBoolean(false);
   out.writeByte((byte) 1);
   out.writeShort((short) -1);
   out.writeInt(-1);
   out.writeVInt(2);
   out.writeLong(-3);
   out.writeVLong(4);
   out.writeOptionalLong(11234234L);
   out.writeFloat(1.1f);
   out.writeDouble(2.2);
   int[] intArray = {1, 2, 3};
   out.writeGenericValue(intArray);
   int[] vIntArray = {4, 5, 6};
   out.writeVIntArray(vIntArray);
   long[] longArray = {1, 2, 3};
   out.writeGenericValue(longArray);
   long[] vLongArray = {4, 5, 6};
   out.writeVLongArray(vLongArray);
   float[] floatArray = {1.1f, 2.2f, 3.3f};
   out.writeGenericValue(floatArray);
   double[] doubleArray = {1.1, 2.2, 3.3};
   out.writeGenericValue(doubleArray);
   out.writeString("hello");
   out.writeString("goodbye");
   out.writeGenericValue(BytesRefs.toBytesRef("bytesref"));
   out.writeStringArray(new String[] {"a", "b", "cat"});
   out.writeBytesReference(new BytesArray("test"));
   out.writeOptionalBytesReference(new BytesArray("test"));
   out.writeOptionalDouble(null);
   out.writeOptionalDouble(1.2);
   out.writeTimeZone(DateTimeZone.forID("CET"));
   out.writeOptionalTimeZone(DateTimeZone.getDefault());
   out.writeOptionalTimeZone(null);
   final byte[] bytes = BytesReference.toBytes(out.bytes());
   StreamInput in = StreamInput.wrap(BytesReference.toBytes(out.bytes()));
   assertEquals(in.available(), bytes.length);
   assertThat(in.readBoolean(), equalTo(false));
   assertThat(in.readByte(), equalTo((byte) 1));
   assertThat(in.readShort(), equalTo((short) -1));
   assertThat(in.readInt(), equalTo(-1));
   assertThat(in.readVInt(), equalTo(2));
   assertThat(in.readLong(), equalTo(-3L));
   assertThat(in.readVLong(), equalTo(4L));
   assertThat(in.readOptionalLong(), equalTo(11234234L));
   assertThat((double) in.readFloat(), closeTo(1.1, 0.0001));
   assertThat(in.readDouble(), closeTo(2.2, 0.0001));
   assertThat(in.readGenericValue(), equalTo((Object) intArray));
   assertThat(in.readVIntArray(), equalTo(vIntArray));
   assertThat(in.readGenericValue(), equalTo((Object) longArray));
   assertThat(in.readVLongArray(), equalTo(vLongArray));
   assertThat(in.readGenericValue(), equalTo((Object) floatArray));
   assertThat(in.readGenericValue(), equalTo((Object) doubleArray));
   assertThat(in.readString(), equalTo("hello"));
   assertThat(in.readString(), equalTo("goodbye"));
   assertThat(in.readGenericValue(), equalTo((Object) BytesRefs.toBytesRef("bytesref")));
   assertThat(in.readStringArray(), equalTo(new String[] {"a", "b", "cat"}));
   assertThat(in.readBytesReference(), equalTo(new BytesArray("test")));
   assertThat(in.readOptionalBytesReference(), equalTo(new BytesArray("test")));
   assertNull(in.readOptionalDouble());
   assertThat(in.readOptionalDouble(), closeTo(1.2, 0.0001));
   assertEquals(DateTimeZone.forID("CET"), in.readTimeZone());
   assertEquals(DateTimeZone.getDefault(), in.readOptionalTimeZone());
   assertNull(in.readOptionalTimeZone());
   assertEquals(0, in.available());
   in.close();
   out.close();
 }
  public void readFrom(StreamInput in, InternalSearchHits.StreamContext context)
      throws IOException {
    score = in.readFloat();
    id = in.readText();
    type = in.readText();
    nestedIdentity = in.readOptionalStreamable(new InternalNestedIdentity());
    version = in.readLong();
    source = in.readBytesReference();
    if (source.length() == 0) {
      source = null;
    }
    if (in.readBoolean()) {
      explanation = readExplanation(in);
    }
    int size = in.readVInt();
    if (size == 0) {
      fields = ImmutableMap.of();
    } else if (size == 1) {
      SearchHitField hitField = readSearchHitField(in);
      fields = ImmutableMap.of(hitField.name(), hitField);
    } else if (size == 2) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2);
    } else if (size == 3) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3);
    } else if (size == 4) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      SearchHitField hitField4 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3,
              hitField4.name(),
              hitField4);
    } else if (size == 5) {
      SearchHitField hitField1 = readSearchHitField(in);
      SearchHitField hitField2 = readSearchHitField(in);
      SearchHitField hitField3 = readSearchHitField(in);
      SearchHitField hitField4 = readSearchHitField(in);
      SearchHitField hitField5 = readSearchHitField(in);
      fields =
          ImmutableMap.of(
              hitField1.name(),
              hitField1,
              hitField2.name(),
              hitField2,
              hitField3.name(),
              hitField3,
              hitField4.name(),
              hitField4,
              hitField5.name(),
              hitField5);
    } else {
      ImmutableMap.Builder<String, SearchHitField> builder = ImmutableMap.builder();
      for (int i = 0; i < size; i++) {
        SearchHitField hitField = readSearchHitField(in);
        builder.put(hitField.name(), hitField);
      }
      fields = builder.build();
    }

    size = in.readVInt();
    if (size == 0) {
      highlightFields = ImmutableMap.of();
    } else if (size == 1) {
      HighlightField field = readHighlightField(in);
      highlightFields = ImmutableMap.of(field.name(), field);
    } else if (size == 2) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      highlightFields = ImmutableMap.of(field1.name(), field1, field2.name(), field2);
    } else if (size == 3) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      HighlightField field3 = readHighlightField(in);
      highlightFields =
          ImmutableMap.of(field1.name(), field1, field2.name(), field2, field3.name(), field3);
    } else if (size == 4) {
      HighlightField field1 = readHighlightField(in);
      HighlightField field2 = readHighlightField(in);
      HighlightField field3 = readHighlightField(in);
      HighlightField field4 = readHighlightField(in);
      highlightFields =
          ImmutableMap.of(
              field1.name(),
              field1,
              field2.name(),
              field2,
              field3.name(),
              field3,
              field4.name(),
              field4);
    } else {
      ImmutableMap.Builder<String, HighlightField> builder = ImmutableMap.builder();
      for (int i = 0; i < size; i++) {
        HighlightField field = readHighlightField(in);
        builder.put(field.name(), field);
      }
      highlightFields = builder.build();
    }

    size = in.readVInt();
    if (size > 0) {
      sortValues = new Object[size];
      for (int i = 0; i < sortValues.length; i++) {
        byte type = in.readByte();
        if (type == 0) {
          sortValues[i] = null;
        } else if (type == 1) {
          sortValues[i] = in.readString();
        } else if (type == 2) {
          sortValues[i] = in.readInt();
        } else if (type == 3) {
          sortValues[i] = in.readLong();
        } else if (type == 4) {
          sortValues[i] = in.readFloat();
        } else if (type == 5) {
          sortValues[i] = in.readDouble();
        } else if (type == 6) {
          sortValues[i] = in.readByte();
        } else if (type == 7) {
          sortValues[i] = in.readShort();
        } else if (type == 8) {
          sortValues[i] = in.readBoolean();
        } else if (type == 9) {
          sortValues[i] = in.readText();
        } else {
          throw new IOException("Can't match type [" + type + "]");
        }
      }
    }

    size = in.readVInt();
    if (size > 0) {
      matchedQueries = new String[size];
      for (int i = 0; i < size; i++) {
        matchedQueries[i] = in.readString();
      }
    }

    if (context.streamShardTarget() == InternalSearchHits.StreamContext.ShardTargetType.STREAM) {
      if (in.readBoolean()) {
        shard = readSearchShardTarget(in);
      }
    } else if (context.streamShardTarget()
        == InternalSearchHits.StreamContext.ShardTargetType.LOOKUP) {
      int lookupId = in.readVInt();
      if (lookupId > 0) {
        shard = context.handleShardLookup().get(lookupId);
      }
    }

    size = in.readVInt();
    if (size > 0) {
      innerHits = new HashMap<>(size);
      for (int i = 0; i < size; i++) {
        String key = in.readString();
        InternalSearchHits value =
            InternalSearchHits.readSearchHits(
                in,
                InternalSearchHits.streamContext()
                    .streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.NO_STREAM));
        innerHits.put(key, value);
      }
    }
  }
 @Override
 public SearchSourceBuilder readFrom(StreamInput in) throws IOException {
   SearchSourceBuilder builder = new SearchSourceBuilder();
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> aggregations = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       aggregations.add(in.readBytesReference());
     }
     builder.aggregations = aggregations;
   }
   builder.explain = in.readOptionalBoolean();
   builder.fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
   boolean hasFieldDataFields = in.readBoolean();
   if (hasFieldDataFields) {
     int size = in.readVInt();
     List<String> fieldDataFields = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       fieldDataFields.add(in.readString());
     }
     builder.fieldDataFields = fieldDataFields;
   }
   boolean hasFieldNames = in.readBoolean();
   if (hasFieldNames) {
     int size = in.readVInt();
     List<String> fieldNames = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       fieldNames.add(in.readString());
     }
     builder.fieldNames = fieldNames;
   }
   builder.from = in.readVInt();
   if (in.readBoolean()) {
     builder.highlightBuilder = in.readBytesReference();
   }
   boolean hasIndexBoost = in.readBoolean();
   if (hasIndexBoost) {
     int size = in.readVInt();
     ObjectFloatHashMap<String> indexBoost = new ObjectFloatHashMap<String>(size);
     for (int i = 0; i < size; i++) {
       indexBoost.put(in.readString(), in.readFloat());
     }
     builder.indexBoost = indexBoost;
   }
   if (in.readBoolean()) {
     builder.innerHitsBuilder = in.readBytesReference();
   }
   if (in.readBoolean()) {
     builder.minScore = in.readFloat();
   }
   if (in.readBoolean()) {
     builder.postQueryBuilder = in.readQuery();
   }
   if (in.readBoolean()) {
     builder.queryBuilder = in.readQuery();
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> rescoreBuilders = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       rescoreBuilders.add(in.readBytesReference());
     }
     builder.rescoreBuilders = rescoreBuilders;
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<ScriptField> scriptFields = new ArrayList<>(size);
     for (int i = 0; i < size; i++) {
       scriptFields.add(ScriptField.PROTOTYPE.readFrom(in));
     }
     builder.scriptFields = scriptFields;
   }
   builder.size = in.readVInt();
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<BytesReference> sorts = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       sorts.add(in.readBytesReference());
     }
     builder.sorts = sorts;
   }
   if (in.readBoolean()) {
     int size = in.readVInt();
     List<String> stats = new ArrayList<>();
     for (int i = 0; i < size; i++) {
       stats.add(in.readString());
     }
     builder.stats = stats;
   }
   if (in.readBoolean()) {
     builder.suggestBuilder = in.readBytesReference();
   }
   builder.terminateAfter = in.readVInt();
   builder.timeoutInMillis = in.readLong();
   builder.trackScores = in.readBoolean();
   builder.version = in.readOptionalBoolean();
   if (in.readBoolean()) {
     builder.ext = in.readBytesReference();
   }
   return builder;
 }
示例#14
0
  public void readFrom(StreamInput in, InternalSearchHits.StreamContext context)
      throws IOException {
    score = in.readFloat();
    id = in.readText();
    type = in.readText();
    nestedIdentity = in.readOptionalStreamable(InternalNestedIdentity::new);
    version = in.readLong();
    source = in.readBytesReference();
    if (source.length() == 0) {
      source = null;
    }
    if (in.readBoolean()) {
      explanation = readExplanation(in);
    }
    int size = in.readVInt();
    if (size == 0) {
      fields = emptyMap();
    } else if (size == 1) {
      SearchHitField hitField = readSearchHitField(in);
      fields = singletonMap(hitField.name(), hitField);
    } else {
      Map<String, SearchHitField> fields = new HashMap<>();
      for (int i = 0; i < size; i++) {
        SearchHitField hitField = readSearchHitField(in);
        fields.put(hitField.name(), hitField);
      }
      this.fields = unmodifiableMap(fields);
    }

    size = in.readVInt();
    if (size == 0) {
      highlightFields = emptyMap();
    } else if (size == 1) {
      HighlightField field = readHighlightField(in);
      highlightFields = singletonMap(field.name(), field);
    } else {
      Map<String, HighlightField> highlightFields = new HashMap<>();
      for (int i = 0; i < size; i++) {
        HighlightField field = readHighlightField(in);
        highlightFields.put(field.name(), field);
      }
      this.highlightFields = unmodifiableMap(highlightFields);
    }

    size = in.readVInt();
    if (size > 0) {
      sortValues = new Object[size];
      for (int i = 0; i < sortValues.length; i++) {
        byte type = in.readByte();
        if (type == 0) {
          sortValues[i] = null;
        } else if (type == 1) {
          sortValues[i] = in.readString();
        } else if (type == 2) {
          sortValues[i] = in.readInt();
        } else if (type == 3) {
          sortValues[i] = in.readLong();
        } else if (type == 4) {
          sortValues[i] = in.readFloat();
        } else if (type == 5) {
          sortValues[i] = in.readDouble();
        } else if (type == 6) {
          sortValues[i] = in.readByte();
        } else if (type == 7) {
          sortValues[i] = in.readShort();
        } else if (type == 8) {
          sortValues[i] = in.readBoolean();
        } else {
          throw new IOException("Can't match type [" + type + "]");
        }
      }
    }

    size = in.readVInt();
    if (size > 0) {
      matchedQueries = new String[size];
      for (int i = 0; i < size; i++) {
        matchedQueries[i] = in.readString();
      }
    }

    if (context.streamShardTarget() == ShardTargetType.STREAM) {
      if (in.readBoolean()) {
        shard = new SearchShardTarget(in);
      }
    } else if (context.streamShardTarget() == ShardTargetType.LOOKUP) {
      int lookupId = in.readVInt();
      if (lookupId > 0) {
        shard = context.handleShardLookup().get(lookupId);
      }
    }

    size = in.readVInt();
    if (size > 0) {
      innerHits = new HashMap<>(size);
      for (int i = 0; i < size; i++) {
        String key = in.readString();
        ShardTargetType shardTarget = context.streamShardTarget();
        InternalSearchHits value =
            InternalSearchHits.readSearchHits(
                in, context.streamShardTarget(ShardTargetType.NO_STREAM));
        context.streamShardTarget(shardTarget);
        innerHits.put(key, value);
      }
    }
  }
示例#15
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   text = in.readText();
   freq = in.readVInt();
   score = in.readFloat();
 }