public void Percolate_query_must_transform_correclty_to_ES() { var document = new JsonObject().Add("headline", "YM"); var query = new PercolateQuery("query", document); Assert.IsTrue(query.Field == "query"); Assert.IsTrue(query.Document.Property <string>("headline") == "YM"); string json = query.ToString(); var jo = JsonObject.Parse(json); var q = jo.ToQuery(); Assert.IsTrue(q.Type == QueryType.PercolateQuery); query = q as PercolateQuery; Assert.IsTrue(query.Field == "query"); Assert.IsTrue(query.Document.Property <string>("headline") == "YM"); var cs = new ConstantScoreQuery(query); query = cs.Query as PercolateQuery; Assert.IsTrue(query.Field == "query"); Assert.IsTrue(query.Document.Property <string>("headline") == "YM"); json = cs.ToString(); jo = JsonObject.Parse(json); q = jo.ToQuery(); Assert.IsTrue(q.Type == QueryType.ConstantScoreQuery); query = (q as ConstantScoreQuery).Query as PercolateQuery; Assert.IsTrue(query.Field == "query"); Assert.IsTrue(query.Document.Property <string>("headline") == "YM"); }
public void Constant_score_query_must_transform_correclty_to_ES() { var query = new ConstantScoreQuery(new MatchQuery("headline", "Yuri Metelkin", true)); Assert.IsTrue(query.Query.Type == QueryType.MatchQuery); Assert.IsTrue(((MatchQuery)query.Query).Field == "headline"); Assert.IsTrue(((MatchQuery)query.Query).Value.ToString() == "Yuri Metelkin"); Assert.IsTrue(((MatchQuery)query.Query).IsAnd); var json = query.ToString(); var jo = JsonObject.Parse(json); var q = jo.ToQuery(); Assert.IsTrue(q.Type == QueryType.ConstantScoreQuery); var cs = q as ConstantScoreQuery; var match = cs.Query as MatchQuery; Assert.IsTrue(match.Field == "headline"); Assert.IsTrue(match.Value.ToString() == "Yuri Metelkin"); Assert.IsTrue(match.IsAnd); }