@Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeUTF(index);
   out.writeVInt(shardId);
   out.writeByte(searchType.id());
   out.writeVInt(numberOfShards);
   if (scroll == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     scroll.writeTo(out);
   }
   out.writeBytesReference(source);
   out.writeBytesReference(extraSource);
   out.writeVInt(types.length);
   for (String type : types) {
     out.writeUTF(type);
   }
   if (filteringAliases != null) {
     out.writeVInt(filteringAliases.length);
     for (String index : filteringAliases) {
       out.writeUTF(index);
     }
   } else {
     out.writeVInt(0);
   }
   out.writeVLong(nowInMillis);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeVInt(shardId);
   out.writeOptionalString(preference);
   out.writeVInt(items.size());
   for (Item item : items) {
     out.writeVInt(item.slot);
     OriginalIndices.writeOriginalIndices(item.request.originalIndices(), out);
     out.writeString(item.request.documentType());
     out.writeBytesReference(item.request.source());
     out.writeBytesReference(item.request.docSource());
     out.writeBoolean(item.request.onlyCount());
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeByte(percolatorTypeId);
   out.writeVLong(requestedSize);
   out.writeVLong(count);
   out.writeVInt(matches.length);
   for (BytesRef match : matches) {
     out.writeBytesRef(match);
   }
   out.writeVLong(scores.length);
   for (float score : scores) {
     out.writeFloat(score);
   }
   out.writeVInt(hls.size());
   for (Map<String, HighlightField> hl : hls) {
     out.writeVInt(hl.size());
     for (Map.Entry<String, HighlightField> entry : hl.entrySet()) {
       out.writeString(entry.getKey());
       entry.getValue().writeTo(out);
     }
   }
   out.writeOptionalStreamable(aggregations);
   if (pipelineAggregators == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     out.writeVInt(pipelineAggregators.size());
     for (PipelineAggregator pipelineAggregator : pipelineAggregators) {
       out.writeBytesReference(pipelineAggregator.type().stream());
       pipelineAggregator.writeTo(out);
     }
   }
 }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    if (out.getVersion().before(Version.V_1_4_0)) {
      // term vector used to read & write the index twice, here and in the parent class
      out.writeString(index);
    }
    out.writeString(type);
    out.writeString(id);

    if (out.getVersion().onOrAfter(Version.V_1_4_0)) {
      out.writeBoolean(doc != null);
      if (doc != null) {
        out.writeBytesReference(doc);
      }
    }
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    long longFlags = 0;
    for (Flag flag : flagsEnum) {
      longFlags |= (1 << flag.ordinal());
    }
    out.writeVLong(longFlags);
    if (selectedFields != null) {
      out.writeVInt(selectedFields.size());
      for (String selectedField : selectedFields) {
        out.writeString(selectedField);
      }
    } else {
      out.writeVInt(0);
    }
  }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeString(index);
   out.writeString(type);
   out.writeString(id);
   out.writeVLong(docVersion);
   final boolean docExists = isExists();
   out.writeBoolean(docExists);
   out.writeBoolean(artificial);
   out.writeVLong(tookInMillis);
   out.writeBoolean(hasTermVectors());
   if (hasTermVectors()) {
     out.writeBytesReference(headerRef);
     out.writeBytesReference(termVectors);
   }
 }
예제 #6
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(sourceNodeId);
   out.writeLong(transferId.getMostSignificantBits());
   out.writeLong(transferId.getLeastSignificantBits());
   out.writeVLong(currentPos);
   out.writeBytesReference(content);
   out.writeBoolean(isLast);
 }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);

    out.writeBytesReference(source);

    out.writeVInt(types.length);
    for (String type : types) {
      out.writeString(type);
    }

    out.writeBoolean(explain);
  }
예제 #8
0
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeFloat(minScore);
    out.writeOptionalString(routing);
    out.writeOptionalString(preference);
    out.writeBytesReference(source);
    out.writeStringArray(types);

    if (out.getVersion().onOrAfter(Version.V_1_4_0_Beta1)) {
      out.writeVInt(terminateAfter);
    }
  }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeLong(recoveryId);
   shardId.writeTo(out);
   out.writeString(metaData.name());
   out.writeVLong(position);
   out.writeVLong(metaData.length());
   out.writeOptionalString(metaData.checksum());
   out.writeBytesReference(content);
   if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_1_3_0)) {
     out.writeOptionalString(metaData.writtenBy() == null ? null : metaData.writtenBy().name());
   }
 }
예제 #10
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeSharedString(type);
   out.writeOptionalString(id);
   out.writeOptionalString(routing);
   out.writeOptionalString(parent);
   out.writeOptionalString(timestamp);
   out.writeLong(ttl);
   out.writeBytesReference(source);
   out.writeByte(opType.id());
   out.writeBoolean(refresh);
   out.writeLong(version);
   out.writeByte(versionType.getValue());
 }
 @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);
   }
 }
예제 #12
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);
  }
예제 #13
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeString(index);
   out.writeOptionalString(type);
   out.writeString(id);
   out.writeLong(version);
   out.writeBoolean(exists);
   if (exists) {
     out.writeBytesReference(source);
     if (fields == null) {
       out.writeVInt(0);
     } else {
       out.writeVInt(fields.size());
       for (GetField field : fields.values()) {
         field.writeTo(out);
       }
     }
   }
 }
예제 #14
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeOptionalString(type);
   out.writeOptionalString(id);
   out.writeOptionalString(routing);
   out.writeOptionalString(parent);
   if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) {
     out.writeOptionalString(null);
     out.writeOptionalWriteable(null);
   }
   out.writeBytesReference(source);
   out.writeByte(opType.getId());
   out.writeLong(version);
   out.writeByte(versionType.getValue());
   out.writeOptionalString(pipeline);
   out.writeBoolean(isRetry);
   out.writeLong(autoGeneratedTimestamp);
 }
예제 #15
0
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeFloat(minScore);

    out.writeBytesReference(querySource);

    out.writeVInt(types.length);
    for (String type : types) {
      out.writeString(type);
    }
    if (filteringAliases != null) {
      out.writeVInt(filteringAliases.length);
      for (String alias : filteringAliases) {
        out.writeString(alias);
      }
    } else {
      out.writeVInt(0);
    }
    out.writeVLong(nowInMillis);
  }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeBytesReference(text);
 }
 @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);
   }
 }
예제 #18
0
  public void writeTo(StreamOutput out, InternalSearchHits.StreamContext context)
      throws IOException {
    out.writeFloat(score);
    out.writeText(id);
    out.writeText(type);
    out.writeOptionalStreamable(nestedIdentity);
    out.writeLong(version);
    out.writeBytesReference(source);
    if (explanation == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      writeExplanation(out, explanation);
    }
    if (fields == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(fields.size());
      for (SearchHitField hitField : fields().values()) {
        hitField.writeTo(out);
      }
    }
    if (highlightFields == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(highlightFields.size());
      for (HighlightField highlightField : highlightFields.values()) {
        highlightField.writeTo(out);
      }
    }

    if (sortValues.length == 0) {
      out.writeVInt(0);
    } else {
      out.writeVInt(sortValues.length);
      for (Object sortValue : sortValues) {
        if (sortValue == null) {
          out.writeByte((byte) 0);
        } else {
          Class type = sortValue.getClass();
          if (type == String.class) {
            out.writeByte((byte) 1);
            out.writeString((String) sortValue);
          } else if (type == Integer.class) {
            out.writeByte((byte) 2);
            out.writeInt((Integer) sortValue);
          } else if (type == Long.class) {
            out.writeByte((byte) 3);
            out.writeLong((Long) sortValue);
          } else if (type == Float.class) {
            out.writeByte((byte) 4);
            out.writeFloat((Float) sortValue);
          } else if (type == Double.class) {
            out.writeByte((byte) 5);
            out.writeDouble((Double) sortValue);
          } else if (type == Byte.class) {
            out.writeByte((byte) 6);
            out.writeByte((Byte) sortValue);
          } else if (type == Short.class) {
            out.writeByte((byte) 7);
            out.writeShort((Short) sortValue);
          } else if (type == Boolean.class) {
            out.writeByte((byte) 8);
            out.writeBoolean((Boolean) sortValue);
          } else if (sortValue instanceof Text) {
            out.writeByte((byte) 9);
            out.writeText((Text) sortValue);
          } else {
            throw new IOException("Can't handle sort field value of type [" + type + "]");
          }
        }
      }
    }

    if (matchedQueries.length == 0) {
      out.writeVInt(0);
    } else {
      out.writeVInt(matchedQueries.length);
      for (String matchedFilter : matchedQueries) {
        out.writeString(matchedFilter);
      }
    }

    if (context.streamShardTarget() == InternalSearchHits.StreamContext.ShardTargetType.STREAM) {
      if (shard == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        shard.writeTo(out);
      }
    } else if (context.streamShardTarget()
        == InternalSearchHits.StreamContext.ShardTargetType.LOOKUP) {
      if (shard == null) {
        out.writeVInt(0);
      } else {
        out.writeVInt(context.shardHandleLookup().get(shard));
      }
    }

    if (innerHits == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(innerHits.size());
      for (Map.Entry<String, InternalSearchHits> entry : innerHits.entrySet()) {
        out.writeString(entry.getKey());
        entry
            .getValue()
            .writeTo(
                out,
                InternalSearchHits.streamContext()
                    .streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.NO_STREAM));
      }
    }
  }
 @Override
 protected void doWriteTo(StreamOutput out) throws IOException {
   out.writeString(fieldName);
   out.writeBytesReference(functionBytes);
   multiValueMode.writeTo(out);
 }