public ITermsQuery Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver)
        {
            if (reader.GetCurrentJsonToken() != JsonToken.BeginObject)
            {
                return(null);
            }

            ITermsQuery query = new TermsQuery();
            var         count = 0;

            while (reader.ReadIsInObject(ref count))
            {
                var property = reader.ReadPropertyNameSegmentRaw();
                if (Fields.TryGetValue(property, out var value))
                {
                    switch (value)
                    {
                    case 0:
                        query.Boost = reader.ReadDouble();
                        break;

                    case 1:
                        query.Name = reader.ReadString();
                        break;
                    }
                }
                else
                {
                    query.Field = property.Utf8String();
                    ReadTerms(ref reader, query, formatterResolver);
                }
            }

            return(query);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var         filter = new TermsQuery();
            ITermsQuery f      = filter;

            if (reader.TokenType != JsonToken.StartObject)
            {
                return(null);
            }

            var depth = reader.Depth;

            while (reader.Read() && reader.Depth >= depth && reader.Value != null)
            {
                var property = reader.Value as string;
                switch (property)
                {
                case "boost":
                    reader.Read();
                    f.Boost = reader.Value as double?;
                    break;

                case "_name":
                    f.Name = reader.ReadAsString();
                    break;

                default:
                    f.Field = property;
                    //reader.Read();
                    ReadTerms(f, reader, serializer);
                    //reader.Read();
                    break;
                }
            }
            return(filter);
        }