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

            if (!path.AllIndices.HasValue && path.Indices == null)
            {
                path.Indices = new[] { (IndexNameMarker)inferrer.DefaultIndex }
            }
            ;
            if (path.Name.IsNullOrEmpty())
            {
                throw new DslException("missing Repository()");
            }

            var indices = path.Indices.HasAny()
                                ? inferrer.IndexNames(path.Indices)
                                : path.AllIndices.GetValueOrDefault(false)
                                        ? "_all"
                                        : inferrer.DefaultIndex;

            var types = path.Types.HasAny()
                                ? inferrer.TypeNames(path.Types)
                                : null;

            pathInfo.Index = indices;
            pathInfo.Type  = types;
            pathInfo.Name  = path.Name;
        }
    }
Ejemplo n.º 2
0
        public static void SetRouteParameters <TParameters>(
            IQueryPath <TParameters> path,
            IConnectionSettingsValues settings,
            ElasticsearchPathInfo <TParameters> pathInfo)
            where TParameters : IRequestParameters, new()
        {
            var inferrer = new ElasticInferrer(settings);

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

            if (path.Indices.HasAny())
            {
                pathInfo.Index = inferrer.IndexNames(path.Indices);
            }
            else if (path.AllIndices.GetValueOrDefault(false) && !pathInfo.Type.IsNullOrEmpty())
            {
                pathInfo.Index = "_all";
            }
        }