private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer)
        {
            reader.Read();

            if (reader.TokenType == JsonToken.StartObject)
            {
                return(GetCompositeBucket(reader, serializer));
            }

            var key = reader.Value;

            reader.Read();
            var propertyName = (string)reader.Value;

            if (propertyName == Parser.From || propertyName == Parser.To)
            {
                return(GetRangeBucket(reader, serializer, key as string));
            }

            string keyAsString = null;

            if (propertyName == Parser.KeyAsString)
            {
                keyAsString = reader.ReadAsString();
                reader.Read();
            }

            reader.Read();             //doc_count;
            var docCount = reader.Value as long?;

            reader.Read();

            var nextProperty = (string)reader.Value;

            if (nextProperty == Parser.Score)
            {
                return(GetSignificantTermsBucket(reader, serializer, key, keyAsString, docCount));
            }

            long?docCountErrorUpperBound = null;

            if (nextProperty == Parser.DocCountErrorUpperBound)
            {
                reader.Read();
                docCountErrorUpperBound = reader.Value as long?;
                reader.Read();
            }
            var nestedAggregates = this.GetSubAggregates(reader, serializer);
            var bucket           = new KeyedBucket <object>(nestedAggregates)
            {
                Key                     = key,
                KeyAsString             = keyAsString,
                DocCount                = docCount.GetValueOrDefault(0),
                DocCountErrorUpperBound = docCountErrorUpperBound
            };

            return(bucket);
        }
        private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer)
        {
            reader.Read();
            var key = reader.Value;

            reader.Read();
            var propertyName = (string)reader.Value;

            if (propertyName == Parser.From || propertyName == Parser.To)
            {
                return(GetRangeBucket(reader, serializer, key as string));
            }

            var bucket = new KeyedBucket <object> {
                Key = key
            };

            if (propertyName == Parser.KeyAsString)
            {
                bucket.KeyAsString = reader.ReadAsString();
                reader.Read();
            }

            reader.Read();             //doc_count;
            var docCount = reader.Value as long?;

            bucket.DocCount = docCount.GetValueOrDefault(0);
            reader.Read();

            var nextProperty = (string)reader.Value;

            if (nextProperty == Parser.Score)
            {
                return(GetSignificantTermsBucket(reader, serializer, bucket));
            }

            if (nextProperty == Parser.DocCountErrorUpperBound)
            {
                reader.Read();
                bucket.DocCountErrorUpperBound = reader.Value as long?;
                reader.Read();
            }
            bucket.Aggregations = this.GetSubAggregates(reader, serializer);
            return(bucket);
        }
예제 #3
0
        private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer)
        {
            var key = reader.ReadAsString();

            reader.Read();
            var property = reader.Value as string;

            if (property == "from" || property == "to")
            {
                return(GetRangeBucket(reader, serializer, key));
            }

            var keyItem = new KeyedBucket {
                Key = key
            };

            if (property == "key_as_string")
            {
                keyItem.KeyAsString = reader.ReadAsString();
                reader.Read();
            }

            reader.Read();             //doc_count;
            var docCount = reader.Value as long?;

            keyItem.DocCount = docCount.GetValueOrDefault(0);
            reader.Read();

            var nextProperty = reader.Value as string;

            if (nextProperty == "score")
            {
                return(GetSignificantTermsBucket(reader, serializer, keyItem));
            }


            keyItem.Aggregations = this.GetSubAggregates(reader, serializer);
            return(keyItem);
        }
예제 #4
0
        private IBucket GetSignificantTermsBucket(JsonReader reader, JsonSerializer serializer, KeyedBucket keyItem)
        {
            reader.Read();
            var score = reader.Value as double?;

            reader.Read();
            reader.Read();
            var bgCount             = reader.Value as long?;
            var significantTermItem = new SignificantTermsBucket()
            {
                Key      = keyItem.Key,
                DocCount = keyItem.DocCount.GetValueOrDefault(0),
                BgCount  = bgCount.GetValueOrDefault(0),
                Score    = score.GetValueOrDefault(0)
            };

            reader.Read();
            significantTermItem.Aggregations = this.GetSubAggregates(reader, serializer);
            return(significantTermItem);
        }
		private IBucket GetSignificantTermsBucket(JsonReader reader, JsonSerializer serializer, KeyedBucket<object> keyItem)
		{
			reader.Read();
			var score = reader.Value as double?;
			reader.Read();
			reader.Read();
			var bgCount = reader.Value as long?;
			var significantTermItem = new SignificantTermsBucket()
			{
				Key = keyItem.Key as string,
				DocCount = keyItem.DocCount.GetValueOrDefault(0),
				BgCount = bgCount.GetValueOrDefault(0),
				Score = score.GetValueOrDefault(0)
			};
			reader.Read();
			significantTermItem.Aggregations = this.GetSubAggregates(reader, serializer);
			return significantTermItem;
		}
		private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer)
		{
			reader.Read();
			var key = reader.Value;
			reader.Read();
			var propertyName = (string)reader.Value;
			if (propertyName == "from" || propertyName == "to")
				return GetRangeBucket(reader, serializer, key as string);

			var bucket = new KeyedBucket<object> { Key = key };

			if (propertyName == "key_as_string")
			{
				bucket.KeyAsString = reader.ReadAsString();
				reader.Read();
			}

			reader.Read(); //doc_count;
			var docCount = reader.Value as long?;
			bucket.DocCount = docCount.GetValueOrDefault(0);
			reader.Read();

			var nextProperty = (string)reader.Value;
			if (nextProperty == "score")
				return GetSignificantTermsBucket(reader, serializer, bucket);

			bucket.Aggregations = this.GetSubAggregates(reader, serializer);
			return bucket;
		}
		private IBucket GetKeyedBucket(JsonReader reader, JsonSerializer serializer)
		{
			var key = reader.ReadAsString();
			reader.Read();
			var property = reader.Value as string;
			if (property == "from" || property == "to")
				return GetRangeBucket(reader, serializer, key);

			var keyItem = new KeyedBucket {Key = key};

			if (property == "key_as_string")
			{
				keyItem.KeyAsString = reader.ReadAsString();
				reader.Read();
			}

			reader.Read(); //doc_count;
			var docCount = reader.Value as long?;
			keyItem.DocCount = docCount.GetValueOrDefault(0);
			reader.Read();

			var nextProperty = reader.Value as string;
			if (nextProperty == "score")
			{
				return GetSignificantTermsBucket(reader, serializer, keyItem);
			}


			keyItem.Aggregations = this.GetSubAggregates(reader, serializer);
			return keyItem;

		}