public static void SetRouteParameters <TParameters, T>(
            IIndexTypePath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
            where T : class
        {
            var inferrer = new ElasticInferrer(settings);

            if (path.Index == null)
            {
                path.Index = inferrer.IndexName <T>();
            }

            if (path.Type == null)
            {
                path.Type = inferrer.TypeName <T>();
            }

            var index = inferrer.IndexName(path.Index);
            var type  = inferrer.TypeName(path.Type);

            pathInfo.Index = index;
            pathInfo.Type  = type;
        }
        public static void SetRouteParameters <TParameters, T>(
            IIndicesTypePath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
            where T : class
        {
            var inferrer = new ElasticInferrer(settings);

            if (path.Type == null)
            {
                path.Type = inferrer.TypeName <T>();
            }

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

            if (path.AllIndices.GetValueOrDefault(false))
            {
                index = "_all";
            }

            var type = inferrer.TypeName(path.Type);

            pathInfo.Index = index;
            pathInfo.Type  = type;
        }
        public static void SetRouteParameters <TParameters, T>(
            IIndexNamePath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
            where T : class
        {
            if (path.Name == null)
            {
                throw new DslException("missing name route parameter");
            }
            var inferrer = new ElasticInferrer(settings);
            var index    = inferrer.IndexName(path.Index) ?? inferrer.IndexName(typeof(T)) ?? inferrer.DefaultIndex;

            pathInfo.Index = index;
            pathInfo.Name  = path.Name;
        }
Пример #4
0
        public static void SetRouteParameters <TParameters, T>(
            IQueryPath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
            where T : class
        {
            //start out with defaults
            var inferrer = new ElasticInferrer(settings);


            var index = inferrer.IndexName <T>();
            var type  = inferrer.TypeName <T>();

            pathInfo.Index = index;
            pathInfo.Type  = type;

            if (path.Types.HasAny())
            {
                pathInfo.Type = inferrer.TypeNames(path.Types);
            }
            else if (path.AllTypes.GetValueOrDefault(false))
            {
                pathInfo.Type = null;
            }
            else
            {
                pathInfo.Type = inferrer.TypeName <T>();
            }

            if (path.Indices.HasAny())
            {
                pathInfo.Index = inferrer.IndexNames(path.Indices);
            }
            else if (path.AllIndices.GetValueOrDefault(false) && !pathInfo.Type.IsNullOrEmpty())
            {
                pathInfo.Index = "_all";
            }
            else
            {
                pathInfo.Index = path.AllIndices.GetValueOrDefault(false) ? null : inferrer.IndexName <T>();
            }
        }
Пример #5
0
        public static void SetRouteParameters <TParameters>(
            IIndexOptionalPath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
        {
            var inferrer = new ElasticInferrer(settings);

            if (!path.AllIndices.HasValue && path.Index == null)
            {
                path.Index = inferrer.DefaultIndex;
            }

            string index = null;

            if (!path.AllIndices.GetValueOrDefault(false))
            {
                index = inferrer.IndexName(path.Index);
            }

            pathInfo.Index = index;
        }
        public static void SetRouteParameters <TParameters>(
            IIndexTypePath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
        {
            var inferrer = new ElasticInferrer(settings);

            if (path.Index == null)
            {
                throw new DslException("Index() not specified");
            }

            if (path.Type == null)
            {
                throw new DslException("Type() not specified");
            }

            var index = inferrer.IndexName(path.Index);
            var type  = inferrer.TypeName(path.Type);

            pathInfo.Index = index;
            pathInfo.Type  = type;
        }