Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Nest/DSL/Query/MatchQueryDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public interface IMatchQuery : IFieldNameQuery
Operator? Operator { get; set; }

PropertyPathMarker Field { get; set; }

[JsonProperty(PropertyName = "fuzzy_transpositions")]
bool? FuzzyTranspositions { get; set; }
}

public class MatchQuery : PlainQuery, IMatchQuery
Expand Down Expand Up @@ -91,6 +94,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
public string MinimumShouldMatch { get; set; }
public Operator? Operator { get; set; }
public PropertyPathMarker Field { get; set; }
public bool? FuzzyTranspositions { get; set; }
}


Expand Down Expand Up @@ -129,7 +133,9 @@ public class MatchQueryDescriptor<T> : IMatchQuery where T : class

PropertyPathMarker IMatchQuery.Field { get; set; }

bool IQuery.IsConditionless
bool? IMatchQuery.FuzzyTranspositions { get; set; }

bool IQuery.IsConditionless
{
get
{
Expand Down Expand Up @@ -235,6 +241,12 @@ public MatchQueryDescriptor<T> Operator(Operator op)
Self.Operator = op;
return this;
}

public MatchQueryDescriptor<T> FuzzyTranspositions(bool transpositions = true)
{
Self.FuzzyTranspositions = transpositions;
return this;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
fq.PrefixLength = GetPropValue<int?>(jo, "prefix_length");
fq.Query = GetPropValue<string>(jo, "query");
fq.Slop = GetPropValue<int?>(jo, "slop");
fq.FuzzyTranspositions = GetPropValue<bool?>(jo, "fuzzy_transpositions");

var rewriteString = GetPropValue<string>(jo, "rewrite");
if (!rewriteString.IsNullOrEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void Match_Deserializes()
.Query("querytext")
.Rewrite(RewriteMultiTerm.ConstantScoreBoolean)
.Slop(2)
.FuzzyTranspositions()
)
);

Expand All @@ -41,6 +42,7 @@ public void Match_Deserializes()
q.Query.Should().Be("querytext");
q.Rewrite.Should().Be(RewriteMultiTerm.ConstantScoreBoolean);
q.Slop.Should().Be(2);
q.FuzzyTranspositions.Should().BeTrue();
}

[Test]
Expand All @@ -61,6 +63,7 @@ public void MatchPhrasePhrefix_Deserializes()
.Query("querytext")
.Rewrite(RewriteMultiTerm.ConstantScoreBoolean)
.Slop(2)
.FuzzyTranspositions(false)
)
);
q.Type.Should().Be("phrase_prefix");
Expand All @@ -76,6 +79,7 @@ public void MatchPhrasePhrefix_Deserializes()
q.Query.Should().Be("querytext");
q.Rewrite.Should().Be(RewriteMultiTerm.ConstantScoreBoolean);
q.Slop.Should().Be(2);
q.FuzzyTranspositions.Should().BeFalse();
}

[Test]
Expand Down