Exemple #1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            NotFilter term = (NotFilter)value;

            if (term != null)
            {
                writer.WriteStartObject();
                writer.WritePropertyName("not");
                writer.WriteStartObject();
                writer.WritePropertyName("filter");
//                writer.WriteStartArray();
//                foreach (var filter in term.Filters)
//                {
                serializer.Serialize(writer, term.Filter);
//                }
//                writer.WriteEndArray();
                writer.WriteEndObject();
//                writer.WriteRaw(",\"_cache\": " + term.Cache.ToString().ToLower());
                writer.WriteEndObject();
            }
        }
        public void TestNotFilter()
        {
            var termFilter = new TermFilter("age", 24);
            var notFilter = new NotFilter(termFilter);

            var termQuery = new TermQuery("type", "common");

            var q = new FilteredQuery(termQuery, notFilter);

            var result2 = client.Search(index, "type" , q, 0, 5);
            Assert.AreEqual(2, result2.GetTotalCount());
            Assert.AreEqual(2, result2.GetHits().Hits.Count);
        }