/// <summary>
        /// Create index with settings
        /// </summary>
        /// <param name="index"></param>
        /// <param name="indexSetting"></param>
        /// <returns></returns>
        public BaseResponse Index(string index, IndexSetting indexSetting)
        {
            string indexUrl = RESTfulESUrlBuilder.Init().Index(index).Host(clusterName).Url();
            var    settings = new IndexSettingWrapper(indexSetting);

            return(restServiceClient.Post <IndexSettingWrapper, BaseResponse>(indexUrl, settings));
        }
예제 #2
0
        //constructor
        public IndexForm()
        {
            InitializeComponent();
            indexSetting    = new IndexSetting();
            luceneIndex_app = new LuceneSearch();
            articles        = new List <JournalArticle>();

            //default path for index object and articles
            docPathLabel.Text   = @"D:\IFN647_prj\crandocs";
            indexPathLabel.Text = @"D:\IFN647_prj\index";
        }
예제 #3
0
 /// <summary>
 /// Updates the status file with the IndexSetting value parameter
 /// </summary>
 /// <param name="eIndexSetting">Setting to be applied to the status file</param>
 private void SetCurrentIndex(IndexSetting eIndexSetting)
 {
     try
     {
         StreamWriter sw = File.CreateText(this.CurrentIndexFile);
         sw.WriteLine((eIndexSetting == IndexSetting.IndexA ? CurrentIndex.INDEX_A : CurrentIndex.INDEX_B));
         sw.Close();
     }
     catch (Exception ex)
     {
         //Do something with ex
     }
 }
예제 #4
0
        public OperateResult ModifyIndex(string index, IndexSetting indexSetting)
        {
            Contract.Assert(!string.IsNullOrEmpty(index));
            Contract.Assert(indexSetting != null);

            string url = "/" + index.ToLower() + "/_settings";

            string json = "{{\"number_of_replicas\" : {0}}}".Fill(indexSetting.NumberOfReplicas);

            RestResponse result = _provider.Put(url, json);

            return(GetOperationResult(result));
        }
예제 #5
0
 /// <summary>
 /// Instance method that returns an array of directory paths associated
 /// with the given IndexSetting.
 /// </summary>
 /// <param name="oIndexSettingRefresh">IndexSetting enumeration value</param>
 /// <returns>DirectoryInfo[] of directory paths</returns>
 public DirectoryInfo[] RefreshDirectories(IndexSetting oIndexSettingRefresh)
 {
     this._arRefreshDirectories = null;
     if (oIndexSettingRefresh == IndexSetting.IndexA)
     {
         this._arRefreshDirectories = this._arIndexADirectories;
     }
     else if (oIndexSettingRefresh == IndexSetting.IndexB)
     {
         this._arRefreshDirectories = this._arIndexBDirectories;
     }
     return(this._arRefreshDirectories);
 }
예제 #6
0
        public void SerializeIndexSetting()
        {
            JsonSerializer jsonSerializer = new JsonSerializer();
            IndexSetting   indexSetting   = new IndexSetting()
            {
                Replicas = 1, Shards = 5
            };
            string jsonString = jsonSerializer.Serialize(indexSetting);
            var    setting    = new { Settings = indexSetting };

            jsonString = jsonSerializer.Serialize(setting);
            Console.WriteLine(jsonString);
        }
예제 #7
0
        public OperateResult CreateIndex(string index, IndexSetting indexSetting)
        {
            Contract.Assert(!string.IsNullOrEmpty(index));
            Contract.Assert(indexSetting != null);

            string url = "/" + index.ToLower() + "/";

            string json = JsonSerializer.Get(indexSetting);

            json = "{    index : " + json + " }";

            RestResponse result = _provider.Post(url, json);

            return(GetOperationResult(result));
        }
예제 #8
0
        public static List <IndexSetting> GenerateIndexsFromParameters(Type ValueType, ObjectStoreParameters parameters)
        {
            List <IndexSetting> indexlist = new List <IndexSetting>();

            // create the index setting.
            foreach (var item in parameters.IndexList)
            {
                IndexSetting index = new IndexSetting();
                index.FieldName = item.Key;

                FieldInfo fieldinfo = ValueType.GetField(item.Key);

                if (fieldinfo != null)
                {
                    index.KeyType = fieldinfo.FieldType;
                }
                else
                {
                    //try get property.
                    PropertyInfo propertyinfo = ValueType.GetProperty(item.Key);
                    if (propertyinfo != null)
                    {
                        index.KeyType = propertyinfo.PropertyType;
                    }
                    else
                    {
                        throw new Exception("field or property does not exists " + item);
                    }
                }

                index.unique = false;  /// this should always be false for all additional index.unique should be checked by contraints.

                index.keyLength = Helper.KeyHelper.GetKeyLen(index.KeyType, index.keyLength);

                indexlist.Add(index);
            }

            return(indexlist);
        }
예제 #9
0
파일: ESCore.cs 프로젝트: lijinchuan/TestES
        /// <summary>
        /// 创建索引
        /// </summary>
        /// <param name="indexname"></param>
        /// <param name="number_of_shards"></param>
        /// <param name="number_of_replicas"></param>
        /// <returns></returns>
        public bool CreateIndex(string indexname, IndexSetting setting, Mappings mappings)
        {
            if (string.IsNullOrWhiteSpace(indexname))
            {
                throw new ArgumentNullException("indexname");
            }

            string data = string.Format("{{{0},{1}}}", setting.ToString(), mappings.ToString());



            var httpresponse = esreqest.DoRequest(_esBaseUrl + indexname, data, WebRequestMethodEnum.PUT, false);

            if (!httpresponse.Successed)
            {
                return(false);
            }

            var response = JsonHelper.JsonToEntity <AcknowledgedResponse>(httpresponse.ResponseContent);

            return(response.Acknowledged);
        }
예제 #10
0
		/// <summary>
		/// Updates the status file with the IndexSetting value parameter
		/// </summary>
		/// <param name="eIndexSetting">Setting to be applied to the status file</param>
		private void SetCurrentIndex(IndexSetting eIndexSetting)
		{
			try
			{
				StreamWriter sw = File.CreateText(this.CurrentIndexFile);
				sw.WriteLine((eIndexSetting==IndexSetting.IndexA ? CurrentIndex.INDEX_A : CurrentIndex.INDEX_B));
				sw.Close();
			}
			catch (Exception ex)
			{
				//Do something with ex
			}
		}
        /// <summary>
        /// Instance method that returns an array of directory paths associated
        /// with the given IndexSetting.
        /// </summary>
        /// <param name="oIndexSettingRefresh">IndexSetting enumeration value</param>
        /// <returns>DirectoryInfo[] of directory paths</returns>
		public DirectoryInfo[] RefreshDirectories(IndexSetting oIndexSettingRefresh)
		{
			this._arRefreshDirectories=null;
			if (oIndexSettingRefresh==IndexSetting.IndexA)
				this._arRefreshDirectories = this._arIndexADirectories;
			else if (oIndexSettingRefresh==IndexSetting.IndexB)
				this._arRefreshDirectories = this._arIndexBDirectories;
			return this._arRefreshDirectories;
		}