Пример #1
0
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeString(type);
    out.writeString(id);
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(source);
    out.writeStringArray(filteringAlias);
    if (fields != null) {
      out.writeBoolean(true);
      out.writeStringArray(fields);
    } else {
      out.writeBoolean(false);
    }

    FetchSourceContext.optionalWriteToStream(fetchSourceContext, out);
    out.writeVLong(nowInMillis);
  }
    @Override
    public void writeTo(StreamOutput out) throws IOException {
      out.writeString(index);
      out.writeOptionalString(type);
      out.writeString(id);
      out.writeOptionalString(routing);
      if (fields == null) {
        out.writeVInt(0);
      } else {
        out.writeVInt(fields.length);
        for (String field : fields) {
          out.writeString(field);
        }
      }

      out.writeLong(version);
      out.writeByte(versionType.getValue());

      FetchSourceContext.optionalWriteToStream(fetchSourceContext, out);
    }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   boolean hasAggregations = aggregations != null;
   out.writeBoolean(hasAggregations);
   if (hasAggregations) {
     out.writeVInt(aggregations.size());
     for (BytesReference aggregation : aggregations) {
       out.writeBytesReference(aggregation);
     }
   }
   out.writeOptionalBoolean(explain);
   FetchSourceContext.optionalWriteToStream(fetchSourceContext, out);
   boolean hasFieldDataFields = fieldDataFields != null;
   out.writeBoolean(hasFieldDataFields);
   if (hasFieldDataFields) {
     out.writeVInt(fieldDataFields.size());
     for (String field : fieldDataFields) {
       out.writeString(field);
     }
   }
   boolean hasFieldNames = fieldNames != null;
   out.writeBoolean(hasFieldNames);
   if (hasFieldNames) {
     out.writeVInt(fieldNames.size());
     for (String field : fieldNames) {
       out.writeString(field);
     }
   }
   out.writeVInt(from);
   boolean hasHighlightBuilder = highlightBuilder != null;
   out.writeBoolean(hasHighlightBuilder);
   if (hasHighlightBuilder) {
     out.writeBytesReference(highlightBuilder);
   }
   boolean hasIndexBoost = indexBoost != null;
   out.writeBoolean(hasIndexBoost);
   if (hasIndexBoost) {
     out.writeVInt(indexBoost.size());
     for (ObjectCursor<String> key : indexBoost.keys()) {
       out.writeString(key.value);
       out.writeFloat(indexBoost.get(key.value));
     }
   }
   boolean hasInnerHitsBuilder = innerHitsBuilder != null;
   out.writeBoolean(hasInnerHitsBuilder);
   if (hasInnerHitsBuilder) {
     out.writeBytesReference(innerHitsBuilder);
   }
   boolean hasMinScore = minScore != null;
   out.writeBoolean(hasMinScore);
   if (hasMinScore) {
     out.writeFloat(minScore);
   }
   boolean hasPostQuery = postQueryBuilder != null;
   out.writeBoolean(hasPostQuery);
   if (hasPostQuery) {
     out.writeQuery(postQueryBuilder);
   }
   boolean hasQuery = queryBuilder != null;
   out.writeBoolean(hasQuery);
   if (hasQuery) {
     out.writeQuery(queryBuilder);
   }
   boolean hasRescoreBuilders = rescoreBuilders != null;
   out.writeBoolean(hasRescoreBuilders);
   if (hasRescoreBuilders) {
     out.writeVInt(rescoreBuilders.size());
     for (BytesReference rescoreBuilder : rescoreBuilders) {
       out.writeBytesReference(rescoreBuilder);
     }
   }
   boolean hasScriptFields = scriptFields != null;
   out.writeBoolean(hasScriptFields);
   if (hasScriptFields) {
     out.writeVInt(scriptFields.size());
     for (ScriptField scriptField : scriptFields) {
       scriptField.writeTo(out);
     }
   }
   out.writeVInt(size);
   boolean hasSorts = sorts != null;
   out.writeBoolean(hasSorts);
   if (hasSorts) {
     out.writeVInt(sorts.size());
     for (BytesReference sort : sorts) {
       out.writeBytesReference(sort);
     }
   }
   boolean hasStats = stats != null;
   out.writeBoolean(hasStats);
   if (hasStats) {
     out.writeVInt(stats.size());
     for (String stat : stats) {
       out.writeString(stat);
     }
   }
   boolean hasSuggestBuilder = suggestBuilder != null;
   out.writeBoolean(hasSuggestBuilder);
   if (hasSuggestBuilder) {
     out.writeBytesReference(suggestBuilder);
   }
   out.writeVInt(terminateAfter);
   out.writeLong(timeoutInMillis);
   out.writeBoolean(trackScores);
   out.writeOptionalBoolean(version);
   boolean hasExt = ext != null;
   out.writeBoolean(hasExt);
   if (hasExt) {
     out.writeBytesReference(ext);
   }
 }