diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java index 68dcfe03482..598d0cfc792 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java @@ -21,22 +21,22 @@ import java.util.List; * A Hop represents one of potentially many stages in a graph exploration. * Each Hop identifies one or more fields in which it will attempt to find * terms that are significantly connected to the previous Hop. Each field is identified - * using a {@link VertexRequest} - * + * using a {@link VertexRequest} + * *
An example series of Hops on webserver logs would be: *
* Optionally, each hop can contain a "guiding query" that further limits the set of documents considered. - * In our weblog example above we might choose to constrain the second hop to only look at log records that + * In our weblog example above we might choose to constrain the second hop to only look at log records that * had a reponse code of 404. *
*- * If absent, the list of {@link VertexRequest}s is inherited from the prior Hop's list to avoid repeating + * If absent, the list of {@link VertexRequest}s is inherited from the prior Hop's list to avoid repeating * the fields that will be examined at each stage. *
* @@ -64,12 +64,7 @@ public class Hop { } void writeTo(StreamOutput out) throws IOException { - if (guidingQuery == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeQuery(guidingQuery); - } + out.writeOptionalNamedWriteable(guidingQuery); if (vertices == null) { out.writeVInt(0); } else { @@ -81,9 +76,7 @@ public class Hop { } void readFrom(StreamInput in) throws IOException { - if (in.readBoolean()) { - guidingQuery = in.readQuery(); - } + guidingQuery = in.readOptionalNamedWriteable(QueryBuilder.class); int size = in.readVInt(); if (size > 0) { vertices = new ArrayList<>(); @@ -103,9 +96,9 @@ public class Hop { } /** - * Add a field in which this {@link Hop} will look for terms that are highly linked to - * previous hops and optionally the guiding query. - * + * Add a field in which this {@link Hop} will look for terms that are highly linked to + * previous hops and optionally the guiding query. + * * @param fieldName a field in the chosen index */ public VertexRequest addVertexRequest(String fieldName) { @@ -120,8 +113,8 @@ public class Hop { /** * An optional parameter that focuses the exploration on documents that - * match the given query. - * + * match the given query. + * * @param queryBuilder any query */ public void guidingQuery(QueryBuilder> queryBuilder) { @@ -146,4 +139,4 @@ public class Hop { VertexRequest getVertexRequest(int requestNumber) { return getEffectiveVertexRequests().get(requestNumber); } -} \ No newline at end of file +}