コード例 #1
0
ファイル: Search.cs プロジェクト: zhere27/ElasticsearchCRUD
        public void WriteJson(ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter)
        {
            elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

            if (_timeout != null)
            {
                JsonHelper.WriteValue("timeout", _timeout.GetTimeUnit(), elasticsearchCrudJsonWriter, _timeoutSet);
            }
            JsonHelper.WriteValue("from", _from, elasticsearchCrudJsonWriter, _fromSet);
            JsonHelper.WriteValue("size", _size, elasticsearchCrudJsonWriter, _sizeSet);
            JsonHelper.WriteValue("terminate_after", _terminateAfter, elasticsearchCrudJsonWriter, _terminateAfterSet);

            if (_querySet)
            {
                _query.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_filterSet)
            {
                _filter.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_sortSet)
            {
                _sortHolder.WriteJson(elasticsearchCrudJsonWriter);
            }
            elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
        }
コード例 #2
0
ファイル: Search.cs プロジェクト: zhlf1987/DotnetFramework
        public void WriteJson(ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter)
        {
            elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

            if (_timeout != null)
            {
                JsonHelper.WriteValue("timeout", _timeout.GetTimeUnit(), elasticsearchCrudJsonWriter, _timeoutSet);
            }
            JsonHelper.WriteValue("from", _from, elasticsearchCrudJsonWriter, _fromSet);
            JsonHelper.WriteValue("size", _size, elasticsearchCrudJsonWriter, _sizeSet);
            JsonHelper.WriteValue("terminate_after", _terminateAfter, elasticsearchCrudJsonWriter, _terminateAfterSet);

            if (_querySet)
            {
                _query.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_filterSet)
            {
                _filter.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_sortSet)
            {
                _sortHolder.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_aggsSet)
            {
                elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("aggs");
                elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
                foreach (var item in _aggs)
                {
                    item.WriteJson(elasticsearchCrudJsonWriter);
                }

                elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
            }

            if (_highlightSet)
            {
                _highlight.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_rescoreSet)
            {
                elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("rescore");
                elasticsearchCrudJsonWriter.JsonWriter.WriteStartArray();

                foreach (var rescore in _rescore)
                {
                    rescore.WriteJson(elasticsearchCrudJsonWriter);
                }

                elasticsearchCrudJsonWriter.JsonWriter.WriteEndArray();
            }

            elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
        }
コード例 #3
0
        protected void WriteValues(ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter)
        {
            elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(_decayType);
            elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
            elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(_field);
            elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

            JsonHelper.WriteValue("origin", _origin, elasticsearchCrudJsonWriter, _originSet);
            JsonHelper.WriteValue("offset", _offset.GetTimeUnit(), elasticsearchCrudJsonWriter);
            JsonHelper.WriteValue("scale", _scale.GetTimeUnit(), elasticsearchCrudJsonWriter);
            JsonHelper.WriteValue("decay", _decay, elasticsearchCrudJsonWriter, _decaySet);

            elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
            elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
        }
コード例 #4
0
        private void WriteValues(ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter)
        {
            JsonHelper.WriteValue("field", _field, elasticsearchCrudJsonWriter);
            JsonHelper.WriteValue("interval", _interval.GetTimeUnit(), elasticsearchCrudJsonWriter);
            JsonHelper.WriteValue("format", _format, elasticsearchCrudJsonWriter, _formatSet);
            JsonHelper.WriteValue("pre_offset", _preOffset, elasticsearchCrudJsonWriter, _preOffsetSet);
            JsonHelper.WriteValue("post_offset", _postOffset, elasticsearchCrudJsonWriter, _postOffsetSet);
            JsonHelper.WriteValue("pre_zone_adjust_large_interval", _preZoneAdjustLargeInterval, elasticsearchCrudJsonWriter, _preZoneAdjustLargeIntervalSet);
            JsonHelper.WriteValue("post_zone", _preZone, elasticsearchCrudJsonWriter, _preZoneSet);
            JsonHelper.WriteValue("pre_zone", _postZone, elasticsearchCrudJsonWriter, _postZoneSet);
            JsonHelper.WriteValue("time_zone", _timeZone, elasticsearchCrudJsonWriter, _timeZoneSet);

            if (_orderSet)
            {
                _order.WriteJson(elasticsearchCrudJsonWriter);
            }
            JsonHelper.WriteValue("min_doc_count", _minDocCount, elasticsearchCrudJsonWriter, _minDocCountSet);

            if (_extendedBoundsSet)
            {
                _extendedBounds.WriteJson(elasticsearchCrudJsonWriter);
            }

            if (_scriptSet)
            {
                elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("script");
                elasticsearchCrudJsonWriter.JsonWriter.WriteRawValue("\"" + _script + "\"");
                if (_paramsSet)
                {
                    elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("params");
                    elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

                    foreach (var item in _params)
                    {
                        elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(item.ParameterName);
                        elasticsearchCrudJsonWriter.JsonWriter.WriteValue(item.ParameterValue);
                    }
                    elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
                }
            }
        }
コード例 #5
0
 public string GetScrollScanUrlForSetup()
 {
     return(string.Format("search_type=scan&scroll={0}&size={1}", _lengthOfTime.GetTimeUnit(), _size));
 }