Exemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var j = JObject.Load(reader);

            if (!j.HasValues)
            {
                return(null);
            }

            var firstProp = j.Properties().FirstOrDefault();

            if (firstProp == null)
            {
                return(null);
            }

            var field = firstProp.Name;
            var jo    = firstProp.Value.Value <JObject>();

            if (jo == null)
            {
                return(null);
            }

            ISpanTermQuery fq = new SpanTermQueryDescriptor <object>();

            fq.Field = field;
            fq.Boost = GetPropValue <double?>(jo, "boost");
            fq.Value = GetPropValue <string>(jo, "value");

            return(fq);
        }
        /// <summary>
        /// Matches spans containing a term. The span term query maps to Lucene SpanTermQuery.
        /// </summary>
        public QueryContainer SpanTerm(Action <SpanTermQueryDescriptor <T> > spanTermSelector)
        {
            var spanTerm = new SpanTermQueryDescriptor <T>();

            spanTermSelector(spanTerm);
            return(this.New(spanTerm, q => q.SpanTerm = spanTerm));
        }