Ejemplo n.º 1
0
 /// <summary>
 /// The index to execute the search on. Defaults to the default index
 /// </summary>
 public TDescriptor Index(IndexNameMarker index)
 {
     if (index == null)
     {
         return((TDescriptor)this);
     }
     return(this.Indices(index));
 }
Ejemplo n.º 2
0
 public string IndexName(IndexNameMarker index)
 {
     if (index == null)
     {
         return(null);
     }
     return(index.Resolve(this._connectionSettings));
 }
Ejemplo n.º 3
0
        internal string GetIndexForType(IndexNameMarker i)
        {
            if (i == null)
            {
                return(this.GetIndexForType((Type)null));
            }

            return(i.Name ?? this.GetIndexForType(i.Type));
        }
Ejemplo n.º 4
0
        public virtual async Task <IIndicesResponse> DeleteIndexAsync()
        {
            var client         = GetClient();
            var indexNameMaker = new IndexNameMarker()
            {
                Type = typeof(T),
                Name = _indexName
            };

            return(await client.DeleteIndexAsync(new DeleteIndexRequest(indexNameMaker)));
        }
        public void IndexNameMarkerEqualsDoesNotUseHashCode()
        {
            var collision = GetHashCollison();

            var indexMarker1 = new IndexNameMarker {
                Name = collision.Item1
            };
            var indexMarker2 = new IndexNameMarker {
                Name = collision.Item2
            };

            this.TestAddingToDictionary(indexMarker1, indexMarker2);
        }
Ejemplo n.º 6
0
 public DeleteByQueryRequest(IndexNameMarker index, TypeNameMarker type = null)
 {
     this.Indices = new [] { index };
     if (type != null)
     {
         this.Types = new[] { type }
     }
     ;
     else
     {
         this.AllTypes = true;
     }
 }
Ejemplo n.º 7
0
        public static string Resolve(this IndexNameMarker marker, IConnectionSettingsValues connectionSettings)
        {
            if (marker == null)
            {
                return(null);
            }
            connectionSettings.ThrowIfNull("connectionSettings");

            if (marker.Type == null)
            {
                return(marker.Name);
            }
            return(new IndexNameResolver(connectionSettings).GetIndexForType(marker.Type));
        }
Ejemplo n.º 8
0
        public IOpenSearchableElasticType GetOpenSearchableElasticTypeByNameOrDefault(string indexName, string typeName, Dictionary <string, object> parameters = null)
        {
            var indexNameMarker = new IndexNameMarker();

            indexNameMarker.Name = indexName;
            var typeNameMarker = new TypeNameMarker();

            typeNameMarker.Name = typeName;
            IOpenSearchableElasticType type = GetOpenSearchableElasticTypeByName(indexName, typeName);

            if (type == null)
            {
                type = new GenericJsonOpenSearchable(indexName, typeName);
            }

            return(type);
        }
Ejemplo n.º 9
0
 public IOpenSearchableElasticType GetOpenSearchableElasticTypeByName(string indexName, string typeName, Dictionary <string, object> parameters = null)
 {
     foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes(typeof(IOpenSearchableElasticType)))
     {
         IOpenSearchableElasticType etype = (IOpenSearchableElasticType)node.CreateInstance();
         if (etype.Identifier == typeName)
         {
             Type type = node.Type;
             var  ctor = type.GetConstructor(new Type[2] {
                 typeof(IndexNameMarker), typeof(TypeNameMarker)
             });
             var indexNameMarker = new IndexNameMarker();
             indexNameMarker.Name = indexName;
             var typeNameMarker = new TypeNameMarker();
             typeNameMarker.Name = typeName;
             etype = (IOpenSearchableElasticType)ctor.Invoke(new object[2] {
                 indexNameMarker, typeNameMarker
             });
             etype.Parameters = parameters;
             return(etype);
         }
     }
     return(null);
 }
Ejemplo n.º 10
0
 public TermvectorRequest(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
Ejemplo n.º 11
0
 public MultiTermVectorsRequest(IndexNameMarker index, TypeNameMarker typeNameMarker) : base(index, typeNameMarker)
 {
 }
Ejemplo n.º 12
0
 public IndexExistsRequest(IndexNameMarker index) : base(index)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Calls putmapping on /{index}/{type}
 /// </summary>
 public PutMappingRequest(IndexNameMarker index, TypeNameMarker type)
 {
     this.Type    = type;
     this.Indices = new [] { index };
 }
Ejemplo n.º 14
0
 public IOpenSearchableElasticType GetOpenSearchableElasticTypeByName(string indexName, string typeName, Dictionary<string, object> parameters = null)
 {
     foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (typeof(IOpenSearchableElasticType))) {
         IOpenSearchableElasticType etype = (IOpenSearchableElasticType)node.CreateInstance();
         if (etype.Identifier == typeName) {
             Type type = node.Type;
             var ctor = type.GetConstructor(new Type[2]{ typeof(IndexNameMarker), typeof(TypeNameMarker) });
             var indexNameMarker = new IndexNameMarker();
             indexNameMarker.Name = indexName;
             var typeNameMarker = new TypeNameMarker();
             typeNameMarker.Name = typeName;
             etype = (IOpenSearchableElasticType)ctor.Invoke(new object[2]{ indexNameMarker, typeNameMarker });
             etype.Parameters = parameters;
             return etype;
         }
     }
     return null;
 }
Ejemplo n.º 15
0
 public SourceRequest(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
 public GenericJsonOpenSearchable(IndexNameMarker index, TypeNameMarker type)
 {
     this.type = type;
     this.index = index;
 }
Ejemplo n.º 17
0
        public IOpenSearchableElasticType GetOpenSearchableElasticTypeByNameOrDefault(string indexName, string typeName, Dictionary<string, object> parameters = null)
        {
            var indexNameMarker = new IndexNameMarker();
            indexNameMarker.Name = indexName;
            var typeNameMarker = new TypeNameMarker();
            typeNameMarker.Name = typeName;
            IOpenSearchableElasticType type = GetOpenSearchableElasticTypeByName(indexName, typeName);

            if (type == null) {
                type = new GenericJsonOpenSearchable(indexName, typeName);
            }

            return type;
        }
Ejemplo n.º 18
0
 protected DocumentPathBase(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
Ejemplo n.º 19
0
        internal IndexInformation CreateCatalogueIndex(Terradue.ElasticCas.Request.CreateIndexRequest createRequest, bool destroy = false)
        {
            if (client.IndexExists(i => i.Index(createRequest.IndexName)).Exists) {

                if (destroy) {
                    client.DeleteIndex(d => d.Index(createRequest.IndexName));
                } else {
                    throw new InvalidOperationException(string.Format("'{0}' index already exists and cannot be overriden without data loss", createRequest.IndexName));
                }
            }

            var response = client.CreateIndex(c => c.Index(createRequest.IndexName));

            IndexInformation indexInformation = new IndexInformation();
            var status = client.Status(s => s.Index(createRequest.IndexName));
            indexInformation.Name = createRequest.IndexName;
            indexInformation.Shards = status.Shards;
            indexInformation.Mappings = new Dictionary<string, ICollection<PropertyNameMarker>>();

            // Init mappings for each types declared
            if (createRequest.TypeNames == null || createRequest.TypeNames.Length == 0) {
                List<string> typeNames = new List<string>();
                foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (typeof(IOpenSearchableElasticType))) {
                    IOpenSearchableElasticType type = (IOpenSearchableElasticType)node.CreateInstance();
                    if (type is GenericJsonOpenSearchable)
                        continue;

                    IndexNameMarker indexName = new IndexNameMarker();
                    indexName.Name = createRequest.IndexName;
                    PutMappingRequest putMappingRequest = new PutMappingRequest(indexName, type.Type);
                    ((IPutMappingRequest)putMappingRequest).Mapping = type.GetRootMapping();

                    client.Map(putMappingRequest);

                    indexInformation.Mappings.Add(type.Identifier, ((IPutMappingRequest)putMappingRequest).Mapping.Properties.Keys);

                    typeNames.Add(type.Type.Name);
                }
                createRequest.TypeNames = typeNames.ToArray();

            } else {
                foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (typeof(IElasticItem))) {
                    IOpenSearchableElasticType type = (IOpenSearchableElasticType)node.CreateInstance();
                    foreach (string typeName in createRequest.TypeNames) {
                        if (typeName == type.Type.Name) {

                            PutMappingRequest putMappingRequest = new PutMappingRequest(type.Index, type.Type);
                            ((IPutMappingRequest)putMappingRequest).Mapping = type.GetRootMapping();

                            client.Map(putMappingRequest);

                            indexInformation.Mappings.Add(type.Identifier, ((IPutMappingRequest)putMappingRequest).Mapping.Properties.Keys);

                        }
                    }
                }
            }

            return indexInformation;
        }
Ejemplo n.º 20
0
 public CreateIndexRequest(IndexNameMarker index) : base(index)
 {
 }
Ejemplo n.º 21
0
 public CloseIndexRequest(IndexNameMarker index) : base(index)
 {
 }
 public DocumentExistsRequest(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
Ejemplo n.º 23
0
        internal IndexInformation CreateCatalogueIndex(Terradue.ElasticCas.Request.CreateIndexRequest createRequest, bool destroy = false)
        {
            if (client.IndexExists(i => i.Index(createRequest.IndexName)).Exists)
            {
                if (destroy)
                {
                    client.DeleteIndex(d => d.Index(createRequest.IndexName));
                }
                else
                {
                    throw new InvalidOperationException(string.Format("'{0}' index already exists and cannot be overriden without data loss", createRequest.IndexName));
                }
            }

            var response = client.CreateIndex(c => c.Index(createRequest.IndexName));

            IndexInformation indexInformation = new IndexInformation();
            var status = client.Status(s => s.Index(createRequest.IndexName));

            indexInformation.Name     = createRequest.IndexName;
            indexInformation.Shards   = status.Shards;
            indexInformation.Mappings = new Dictionary <string, ICollection <PropertyNameMarker> >();

            // Init mappings for each types declared
            if (createRequest.TypeNames == null || createRequest.TypeNames.Length == 0)
            {
                List <string> typeNames = new List <string>();
                foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes(typeof(IOpenSearchableElasticType)))
                {
                    IOpenSearchableElasticType type = (IOpenSearchableElasticType)node.CreateInstance();
                    if (type is GenericJsonOpenSearchable)
                    {
                        continue;
                    }

                    IndexNameMarker indexName = new IndexNameMarker();
                    indexName.Name = createRequest.IndexName;
                    PutMappingRequest putMappingRequest = new PutMappingRequest(indexName, type.Type);
                    ((IPutMappingRequest)putMappingRequest).Mapping = type.GetRootMapping();

                    client.Map(putMappingRequest);

                    indexInformation.Mappings.Add(type.Identifier, ((IPutMappingRequest)putMappingRequest).Mapping.Properties.Keys);

                    typeNames.Add(type.Type.Name);
                }
                createRequest.TypeNames = typeNames.ToArray();
            }
            else
            {
                foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes(typeof(IElasticItem)))
                {
                    IOpenSearchableElasticType type = (IOpenSearchableElasticType)node.CreateInstance();
                    foreach (string typeName in createRequest.TypeNames)
                    {
                        if (typeName == type.Type.Name)
                        {
                            PutMappingRequest putMappingRequest = new PutMappingRequest(type.Index, type.Type);
                            ((IPutMappingRequest)putMappingRequest).Mapping = type.GetRootMapping();

                            client.Map(putMappingRequest);

                            indexInformation.Mappings.Add(type.Identifier, ((IPutMappingRequest)putMappingRequest).Mapping.Properties.Keys);
                        }
                    }
                }
            }

            return(indexInformation);
        }
Ejemplo n.º 24
0
 public GetMappingRequest(IndexNameMarker index, TypeNameMarker typeNameMarker) : base(index, typeNameMarker)
 {
 }
Ejemplo n.º 25
0
 public MoreLikeThisRequest(IndexNameMarker indexName, TypeNameMarker typeName, string id) : base(indexName, typeName, id)
 {
 }
Ejemplo n.º 26
0
 public OpenIndexRequest(IndexNameMarker index) : base(index)
 {
 }
 public GenericJsonOpenSearchable(IndexNameMarker index, TypeNameMarker type)
 {
     this.type  = type;
     this.index = index;
 }
 public IndexNamePathBase(IndexNameMarker index, string name)
 {
     this.Index = index;
     this.Name  = name;
 }
 public GetIndexSettingsRequest(IndexNameMarker index) : base(index)
 {
 }
Ejemplo n.º 30
0
 public IndexPathBase(IndexNameMarker index)
 {
     this.Index = index;
 }
 public UnregisterPercolatorRequest(IndexNameMarker index, string name) : base(index, name)
 {
 }
Ejemplo n.º 32
0
 public DocumentOptionalPathBase(IndexNameMarker indexName, TypeNameMarker typeName, string id)
 {
     this.Index = indexName;
     this.Type  = typeName;
     this.Id    = id;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Does an _optimize on /{index}/_optimize
 /// </summary>
 public OptimizeRequest(IndexNameMarker index)
 {
     this.Indices = new[] { index };
 }
 public IndexTypePathBase(IndexNameMarker index, TypeNameMarker typeNameMarker)
 {
     this.Index = index;
     this.Type  = typeNameMarker;
 }