예제 #1
0
 private static void CopySearchRequestParameters <T>(MoreLikeThisDescriptor <T> d) where T : class
 {
     if (d._Search == null)
     {
         return;
     }
     d._QueryString.CopyQueryStringValuesFrom(d._Search._QueryString);
 }
예제 #2
0
 private static void CopySearchQueryString <T>(MoreLikeThisDescriptor <T> d) where T : class
 {
     if (d._Search != null)
     {
         var searchQs = d._Search._QueryString._QueryStringDictionary;
         foreach (var k in searchQs.Keys)
         {
             d._QueryString._QueryStringDictionary[k] = searchQs[k];
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Search using T as the return type
        /// </summary>
        public IQueryResponse <T> MoreLikeThis <T>(Func <MoreLikeThisDescriptor <T>, MoreLikeThisDescriptor <T> > mltSelector) where T : class
        {
            var mltDescriptor = new MoreLikeThisDescriptor <T>();
            var descriptor    = mltSelector(mltDescriptor);

            var path = this.PathResolver.GetMoreLikeThisPathFor(descriptor);
            ConnectionStatus status = null;

            if (descriptor._Search == null)
            {
                status = this.Connection.GetSync(path);
            }
            else
            {
                var search = this.Serialize(descriptor._Search);
                status = this.Connection.PostSync(path, search);
            }
            return(this.Deserialize <QueryResponse <T> >(status));
        }
        /// <summary>
        /// Search using T as the return type
        /// </summary>
        public IQueryResponse <T> MoreLikeThis <T>(Func <MoreLikeThisDescriptor <T>, MoreLikeThisDescriptor <T> > mltSelector) where T : class
        {
            var mltDescriptor = new MoreLikeThisDescriptor <T>();
            var descriptor    = mltSelector(mltDescriptor);

            var path = this.PathResolver.GetMoreLikeThisPathFor(descriptor);
            ConnectionStatus status = null;

            if (descriptor._Search == null)
            {
                status = this.Connection.GetSync(path);
            }
            else
            {
                var search = this.Serialize(descriptor._Search);
                status = this.Connection.PostSync(path, search);
            }
            return(this.Deserialize <QueryResponse <T> >(status, extraConverters: new List <JsonConverter>
            {
                new ConcreteTypeConverter(typeof(T), (d, h) => typeof(T))
            }));
        }