Example #1
0
 //button click action to start indexing
 private void indexBtn_Click(object sender, EventArgs e)
 {
     if (docPathLabel.Text != "" && indexPathLabel.Text != "")
     {
         string documentPath = docPathLabel.Text;
         //Read all text file in document directory
         textBox.AppendText(indexSetting.ToString());
         WalkDirectoryTree(documentPath);
         //Index
         IndexDocuments();
     }
     else
     {
         MessageBox.Show("Please specify document and index path.",
                         "Important Note",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation,
                         MessageBoxDefaultButton.Button1);
     }
 }
Example #2
0
        /// <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);
        }