Пример #1
0
        internal virtual ElasticsearchPathInfo <K> ToPathInfo <K>(IConnectionSettings settings, K queryString)
            where K : FluentQueryString <K>, new()
        {
            var inferrer = new ElasticInferrer(settings);

            if (this._Index == null)
            {
                this._Index = inferrer.IndexName <T>();
            }
            if (this._Type == null)
            {
                this._Type = inferrer.TypeName <T>();
            }

            var index    = new ElasticInferrer(settings).IndexName(this._Index);
            var type     = new ElasticInferrer(settings).TypeName(this._Type);
            var pathInfo = new ElasticsearchPathInfo <K>()
            {
                Index = index,
                Type  = type
            };

            pathInfo.QueryString = queryString ?? new K();
            return(pathInfo);
        }
Пример #2
0
        internal virtual ElasticsearchPathInfo <K> ToPathInfo <K>(IConnectionSettings settings, K queryString)
            where K : FluentQueryString <K>, new()
        {
            var inferrer = new ElasticInferrer(settings);

            if (this._Type == null)
            {
                this._Type = inferrer.TypeName <T>();
            }

            var index = !this._Indices.HasAny()
                                ? inferrer.IndexName <T>()
                                : string.Join(",", this._Indices.Select(inferrer.IndexName));

            if (this._AllIndices.GetValueOrDefault(false))
            {
                index = "_all";
            }

            var type     = new ElasticInferrer(settings).TypeName(this._Type);
            var pathInfo = new ElasticsearchPathInfo <K>()
            {
                Index = index,
                Type  = type
            };

            pathInfo.QueryString = queryString ?? new K();
            return(pathInfo);
        }
Пример #3
0
        internal virtual ElasticsearchPathInfo <K> ToPathInfo <K>(IConnectionSettingsValues settings, K queryString)
            where K : FluentRequestParameters <K>, new()
        {
            var inferrer = new ElasticInferrer(settings);

            if (this._Index == null)
            {
                this._Index = inferrer.IndexName <T>();
            }
            if (this._Type == null)
            {
                this._Type = inferrer.TypeName <T>();
            }

            var index    = new ElasticInferrer(settings).IndexName(this._Index);
            var type     = new ElasticInferrer(settings).TypeName(this._Type);
            var pathInfo = new ElasticsearchPathInfo <K>()
            {
                Index = index,
                Type  = type
            };

            pathInfo.RequestParameters = queryString ?? new K();
            pathInfo.RequestParameters.RequestConfiguration(r => this._RequestConfiguration);
            return(pathInfo);
        }
        internal virtual ElasticsearchPathInfo <TParameters> ToPathInfo(IConnectionSettingsValues settings, TParameters queryString)
        {
            var inferrer = new ElasticInferrer(settings);

            if (this._Type == null)
            {
                this._Type = inferrer.TypeName <T>();
            }

            var index = !this._Indices.HasAny()
                                ? inferrer.IndexName <T>()
                                : string.Join(",", this._Indices.Select(inferrer.IndexName));

            if (this._AllIndices.GetValueOrDefault(false))
            {
                index = "_all";
            }

            var type     = new ElasticInferrer(settings).TypeName(this._Type);
            var pathInfo = base.ToPathInfo(queryString);

            pathInfo.Index = index;
            pathInfo.Type  = type;
            return(pathInfo);
        }
Пример #5
0
 public ObjectMappingDescriptor(IConnectionSettings connectionSettings)
 {
     this._TypeName = new TypeNameResolver().GetTypeNameFor <TChild>();
     this._Mapping  = new ObjectMapping()
     {
     };
     this._connectionSettings = connectionSettings;
 }
Пример #6
0
 /// <summary>
 /// The type to execute the search on. Defaults to the inferred typename of T
 /// unless T is dynamic then a type (or AllTypes()) MUST be specified.
 /// </summary>
 public TDescriptor Type(TypeNameMarker type)
 {
     if (type == null)
     {
         return((TDescriptor)this);
     }
     return(this.Types(type));
 }
Пример #7
0
 public NestedObjectMappingDescriptor(IConnectionSettings connectionSettings)
 {
     this._connectionSettings = connectionSettings;
     this._TypeName           = TypeNameMarker.Create <TChild>();
     this._Mapping            = new NestedObjectMapping()
     {
     };
 }
Пример #8
0
 public P FixedPath <T>(bool fixateType = false)
 {
     this._Index = typeof(T);
     if (fixateType)
     {
         this._Type = typeof(T);
     }
     return((P)this);
 }
 public TDescriptor FixedPath <TAlternative>(bool fixateType = false)
 {
     this._Index = typeof(TAlternative);
     if (fixateType)
     {
         this._Type = typeof(TAlternative);
     }
     return((TDescriptor)this);
 }
 public RootObjectMappingDescriptor(IConnectionSettings connectionSettings)
 {
     this._connectionSettings = connectionSettings;
     this._TypeName           = TypeNameMarker.Create <T>();
     this._Mapping            = new RootObjectMapping()
     {
         TypeNameMarker = this._TypeName
     };
 }
Пример #11
0
 internal SearchDescriptor <T> Type(TypeNameMarker type)
 {
     if (type == null)
     {
         return(this);
     }
     this._Types = new[] { type };
     return(this);
 }
Пример #12
0
 public NestedObjectMappingDescriptor(IConnectionSettingsValues connectionSettings)
 {
     this._connectionSettings = connectionSettings;
     this._TypeName           = TypeNameMarker.Create <TChild>();
     this._Mapping            = new NestedObjectMapping()
     {
     };
     this.Infer = new ElasticInferrer(this._connectionSettings);
 }
Пример #13
0
        public MultiSearchResponse MultiSearch(MultiSearchDescriptor multiSearchDescriptor)
        {
            multiSearchDescriptor.ThrowIfNull("multiSearchDescriptor");
            var sb = new StringBuilder();

            foreach (var operation in multiSearchDescriptor._Operations.Values)
            {
                var indeces = operation._Indices.HasAny() ? string.Join(",", operation._Indices) : null;
                if (operation._AllIndices)
                {
                    indeces = "_all";
                }

                var index = indeces ??
                            multiSearchDescriptor._FixedIndex ??
                            new IndexNameResolver(this._connectionSettings).GetIndexForType(operation._ClrType);

                var types = operation._Types.HasAny() ? string.Join(",", operation._Types.Select(x => x.Resolve(this._connectionSettings))) : null;

                var typeName = types
                               ?? multiSearchDescriptor._FixedType
                               ?? TypeNameMarker.Create(operation._ClrType);
                if (operation._AllTypes)
                {
                    typeName = null;                     //force empty typename so we'll query all types.
                }
                var op     = new { index = index, type = typeName, search_type = this.GetSearchType(operation), preference = operation._Preference, routing = operation._Routing };
                var opJson = this.Serializer.Serialize(op, Formatting.None);

                var action = "{0}\n".F(opJson);
                sb.Append(action);
                var searchJson = this.Serializer.Serialize(operation, Formatting.None);
                sb.Append(searchJson + "\n");
            }
            var json = sb.ToString();
            var path = "_msearch";

            if (!multiSearchDescriptor._FixedIndex.IsNullOrEmpty())
            {
                if (!multiSearchDescriptor._FixedType.IsNullOrEmpty())
                {
                    path = multiSearchDescriptor._FixedType + "/" + path;
                }
                path = multiSearchDescriptor._FixedIndex + "/" + path;
            }
            var status = this.Connection.PostSync(path, json);

            var multiSearchConverter = new MultiSearchConverter(this._connectionSettings, multiSearchDescriptor);
            var multiSearchResponse  = this.Deserialize <MultiSearchResponse>(status,
                                                                              extraConverters: new List <JsonConverter>
            {
                multiSearchConverter
            });

            return(multiSearchResponse);
        }
        public TemplateMappingDescriptor RemoveMapping <T>()
            where T : class
        {
            var typeName = new TypeNameMarker {
                Type = typeof(T)
            }.Resolve(this._connectionSettings);

            this._TemplateMapping.Mappings.Remove(typeName);
            return(this);
        }
        public PutMappingDescriptor <T> SetParent <K>() where K : class
        {
            var parentType = TypeNameMarker.Create <K>();

            this._Mapping.Parent = new ParentTypeMapping()
            {
                Type = parentType
            };
            return(this);
        }
Пример #16
0
 public DeleteByQueryRequest(IndexNameMarker index, TypeNameMarker type = null)
 {
     this.Indices = new [] { index };
     if (type != null)
     {
         this.Types = new[] { type }
     }
     ;
     else
     {
         this.AllTypes = true;
     }
 }
Пример #17
0
 protected QueryPathBase(IndexNameMarker index, TypeNameMarker type = null)
 {
     this.Indices = new [] { index };
     if (type != null)
     {
         this.Types = new[] { type }
     }
     ;
     else
     {
         this.AllTypes = true;
     }
 }
Пример #18
0
        internal virtual ElasticsearchPathInfo <TParameter> ToPathInfo(IConnectionSettingsValues settings, TParameter queryString)
        {
            var inferrer = new ElasticInferrer(settings);

            if (this._Index == null)
            {
                this._Index = inferrer.IndexName <T>();
            }
            if (this._Type == null)
            {
                this._Type = inferrer.TypeName <T>();
            }

            var index = inferrer.IndexName(this._Index);
            var type  = inferrer.TypeName(this._Type);

            var pathInfo = base.ToPathInfo(queryString);

            pathInfo.Index = index;
            pathInfo.Type  = type;
            return(pathInfo);
        }
Пример #19
0
 internal static bool IsNullOrEmpty(this TypeNameMarker value)
 {
     return(value == null || value.GetHashCode() == 0);
 }
Пример #20
0
 public TDescriptor Type <TAlternative>() where TAlternative : class
 {
     this._Type = typeof(TAlternative);
     return((TDescriptor)this);
 }
Пример #21
0
 private string ResolveTypeName(TypeNameMarker typeNameMarker, string defaultIndexName = null)
 {
     return(typeNameMarker != null?typeNameMarker.Resolve(this._connectionSettings) : defaultIndexName);
 }
Пример #22
0
 public TopChildrenQueryDescriptor()
 {
     this._Type = TypeNameMarker.Create <T>();
 }
Пример #23
0
 public string TypeName(TypeNameMarker type)
 {
     return(type == null ? null : this.TypeNameResolver.GetTypeNameFor(type));
 }
 public GenericJsonOpenSearchable(IndexNameMarker index, TypeNameMarker type)
 {
     this.type = type;
     this.index = index;
 }
Пример #25
0
 public SourceRequest(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
Пример #26
0
 public TDescriptor Type(Type type)
 {
     this._Type = type;
     return((TDescriptor)this);
 }
 public TypeExistsRequest(IndexNameMarker index, TypeNameMarker typeNameMarker) : base(index, typeNameMarker)
 {
 }
 protected SearchExistsRequest(IndexNameMarker index, TypeNameMarker type = null)
     : base(index, type)
 {
 }
Пример #29
0
 public HasChildQueryDescriptor()
 {
     this._Type = TypeNameMarker.Create <T>();
 }
Пример #30
0
 public IndicesExistsTypeRequest(IndexNameMarker index, TypeNameMarker typeNameMarker) : base(index, typeNameMarker)
 {
 }
Пример #31
0
 public string TypeName(Type t)
 {
     return(TypeNameMarker.Create(t).Resolve(this._connectionSettings));
 }