Skip to content

Commit

Permalink
Make sure to handle backwards compatibility during stream serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtibshirani committed Apr 19, 2018
1 parent 8765293 commit 527d424
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.index.query;

import org.apache.lucene.search.Query;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -71,7 +72,9 @@ public MatchPhraseQueryBuilder(StreamInput in) throws IOException {
fieldName = in.readString();
value = in.readGenericValue();
slop = in.readVInt();
zeroTermsQuery = ZeroTermsQuery.readFromStream(in);
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
zeroTermsQuery = ZeroTermsQuery.readFromStream(in);
}
analyzer = in.readOptionalString();
}

Expand All @@ -80,7 +83,9 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(fieldName);
out.writeGenericValue(value);
out.writeVInt(slop);
zeroTermsQuery.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
zeroTermsQuery.writeTo(out);
}
out.writeOptionalString(analyzer);
}

Expand Down

0 comments on commit 527d424

Please sign in to comment.