public void AddStringMapping(StringMapping stringMapping) { // Add the list, as it's past inspection. var lvI = lvKeys.Items.Add(stringMapping.TextFrom); lvI.SubItems.Add(stringMapping.TextTo); lvI.Tag = stringMapping; lvI.Selected = true; lvKeys.Focus(); }
public void Reindex() { _client.DeleteIndex(IndexType); _client.CreateIndex(IndexType); var indexDefinition = new RootObjectMapping { Properties = new Dictionary <PropertyNameMarker, IElasticType>() }; var paramsProperty = new ObjectMapping { Properties = new Dictionary <PropertyNameMarker, IElasticType>() }; var numberMapping = new NumberMapping(); var boolMapping = new BooleanMapping(); var stringMapping = new StringMapping { Index = FieldIndexOption.NotAnalyzed }; IEnumerable <object> properties = GetAllProperties(); foreach (var property in properties) { //switch (property.DataType) //{ // case DataType.Logic: // paramsProperty.Properties.Add(property.Id, boolMapping); // break; // case DataType.Numeric: // paramsProperty.Properties.Add(property.Id, numberMapping); // break; // case DataType.Text: // paramsProperty.Properties.Add(property.Id, stringMapping); // break; //} } indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.Params), paramsProperty); indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.Id), stringMapping); indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.CategoryId), stringMapping); _client.Map <ProductIndex>(x => x.InitializeUsing(indexDefinition)); IEnumerable <Product> products = GetAllProducts(); _client.IndexMany(products); }
public void CreateIndexMultiFieldMap() { var client = this.Client; var typeMapping = new RootObjectMapping(); typeMapping.Name = Guid.NewGuid().ToString("n"); var property = new MultiFieldMapping(); var primaryField = new StringMapping() { Index = FieldIndexOption.NotAnalyzed }; var analyzedField = new StringMapping() { Index = FieldIndexOption.Analyzed }; property.Fields.Add("name", primaryField); property.Fields.Add("name_analyzed", analyzedField); typeMapping.Properties = typeMapping.Properties ?? new Dictionary <PropertyNameMarker, IElasticType>(); typeMapping.Properties.Add("name", property); var settings = new IndexSettings(); settings.Mappings.Add(typeMapping); settings.NumberOfReplicas = 1; settings.NumberOfShards = 5; settings.Analysis.Analyzers.Add("snowball", new SnowballAnalyzer { Language = "English" }); var indexName = Guid.NewGuid().ToString(); var response = client.CreateIndex(indexName, i => i.InitializeUsing(settings)); Assert.IsTrue(response.IsValid); Assert.IsTrue(response.Acknowledged); var inferrer = new ElasticInferrer(this.Settings); var typeName = inferrer.PropertyName(typeMapping.Name); Assert.IsNotNull(this.Client.GetMapping <ElasticsearchProject>(gm => gm.Index(indexName).Type(typeName))); var deleteResponse = client.DeleteIndex(i => i.Index(indexName)); Assert.IsTrue(deleteResponse.IsValid); Assert.IsTrue(deleteResponse.Acknowledged); }
public void CreateIndexMultiFieldMap() { var client = this._client; var typeMapping = new RootObjectMapping(); typeMapping.TypeNameMarker = Guid.NewGuid().ToString("n"); var property = new MultiFieldMapping(); var primaryField = new StringMapping() { Index = FieldIndexOption.not_analyzed }; var analyzedField = new StringMapping() { Index = FieldIndexOption.analyzed }; property.Fields.Add("name", primaryField); property.Fields.Add("name_analyzed", analyzedField); typeMapping.Properties = typeMapping.Properties ?? new Dictionary <string, IElasticType>(); typeMapping.Properties.Add("name", property); var settings = new IndexSettings(); settings.Mappings.Add(typeMapping); settings.NumberOfReplicas = 1; settings.NumberOfShards = 5; settings.Analysis.Analyzers.Add("snowball", new SnowballAnalyzer { Language = "English" }); var indexName = Guid.NewGuid().ToString(); var response = client.CreateIndex(indexName, settings); Assert.IsTrue(response.IsValid); Assert.IsTrue(response.OK); var typeName = typeMapping.TypeNameMarker.Resolve(this._settings); Assert.IsNotNull(this._client.GetMapping(indexName, typeName)); var deleteResponse = client.DeleteIndex(indexName); Assert.IsTrue(deleteResponse.IsValid); Assert.IsTrue(deleteResponse.OK); }
void LvKeys_SelectedIndexChanged(object sender, EventArgs e) { // UI stuff (to prevent editing or deleting a non-item if (lvKeys.SelectedItems.Count <= 0) { m_stringMapping = null; btnEdit.Enabled = mniEdit.Enabled = false; btnDelete.Enabled = mniDelete.Enabled = false; } else { m_stringMapping = (StringMapping)lvKeys.SelectedItems[0].Tag; btnEdit.Enabled = mniEdit.Enabled = true; btnDelete.Enabled = mniDelete.Enabled = true; } }
protected void SetTtl(String type, String defaultDuration) { if (!Client.IndexExists(x => x.Index(EsIndex)).Exists) { _log.Info("Create ES index: " + EsIndex); var response = Client.CreateIndex(EsIndex, id => id.NumberOfShards(2)); } var indexDefinition = new RootObjectMapping { Properties = new Dictionary <PropertyNameMarker, IElasticType>(), Name = "log", }; var ttlDescriptor = new TtlFieldMappingDescriptor(); ttlDescriptor.Enable(true); ttlDescriptor.Default(defaultDuration); indexDefinition.TtlFieldMappingDescriptor = ttlDescriptor; var notAnalyzedProperty = new StringMapping { Index = FieldIndexOption.NotAnalyzed }; //property.Fields.Add("le", property); indexDefinition.Properties.Add("le", notAnalyzedProperty); indexDefinition.Properties.Add("us", notAnalyzedProperty); indexDefinition.Properties.Add("lo", notAnalyzedProperty); indexDefinition.Properties.Add("do", notAnalyzedProperty); indexDefinition.Properties.Add("ma", notAnalyzedProperty); indexDefinition.Properties.Add("pn", notAnalyzedProperty); indexDefinition.Properties.Add("ln", notAnalyzedProperty); indexDefinition.Properties.Add("cn", notAnalyzedProperty); indexDefinition.Properties.Add("ts", new DateMapping()); indexDefinition.Properties.Add("mongo-server", notAnalyzedProperty); indexDefinition.Properties.Add("collection", notAnalyzedProperty); indexDefinition.Properties.Add("source", notAnalyzedProperty); Client.Map <object>(x => x .InitializeUsing(indexDefinition) .Index(EsIndex) .Type("log") ); _log.Info("ES Mapping set"); }
public void CreateIndexMultiFieldMap() { var client = this._client; var typeMapping = new RootObjectMapping(); typeMapping.Name = Guid.NewGuid().ToString("n"); var property = new MultiFieldMapping(); var primaryField = new StringMapping() { Index = FieldIndexOption.not_analyzed }; var analyzedField = new StringMapping() { Index = FieldIndexOption.analyzed }; property.Fields.Add("name", primaryField); property.Fields.Add("name_analyzed", analyzedField); typeMapping.Properties = typeMapping.Properties ?? new Dictionary<PropertyNameMarker, IElasticType>(); typeMapping.Properties.Add("name", property); var settings = new IndexSettings(); settings.Mappings.Add(typeMapping); settings.NumberOfReplicas = 1; settings.NumberOfShards = 5; settings.Analysis.Analyzers.Add("snowball", new SnowballAnalyzer { Language = "English" }); var indexName = Guid.NewGuid().ToString(); var response = client.CreateIndex(indexName, i=>i.InitializeUsing(settings)); Assert.IsTrue(response.IsValid); Assert.IsTrue(response.Acknowledged); var inferrer = new ElasticInferrer(this._settings); var typeName = inferrer.PropertyName(typeMapping.Name); Assert.IsNotNull(this._client.GetMapping(gm=>gm.Index(indexName).Type(typeName))); var deleteResponse = client.DeleteIndex(i=>i.Index(indexName)); Assert.IsTrue(deleteResponse.IsValid); Assert.IsTrue(deleteResponse.Acknowledged); }
public void PutMapping() { var fieldName = Guid.NewGuid().ToString(); var mapping = this.Client.GetMapping <ElasticsearchProject>().Mapping; var property = new StringMapping { Index = FieldIndexOption.NotAnalyzed }; mapping.Properties.Add(fieldName, property); var response = this.Client.Map <ElasticsearchProject>(m => m.InitializeUsing(mapping)); Assert.IsTrue(response.IsValid, response.ConnectionStatus.ToString()); Assert.IsTrue(response.Acknowledged, response.ConnectionStatus.ToString()); mapping = this.Client.GetMapping <ElasticsearchProject>(gm => gm.Index <ElasticsearchProject>().Type <ElasticsearchProject>()).Mapping; Assert.IsNotNull(mapping.Properties.ContainsKey(fieldName)); }
public void PutMapping() { var fieldName = Guid.NewGuid().ToString(); var mapping = this._client.GetMapping <ElasticSearchProject>(); var property = new StringMapping { Index = FieldIndexOption.not_analyzed }; mapping.Properties.Add(fieldName, property); var response = this._client.Map(mapping); Assert.IsTrue(response.IsValid, response.ConnectionStatus.ToString()); Assert.IsTrue(response.OK, response.ConnectionStatus.ToString()); mapping = this._client.GetMapping <ElasticSearchProject>(); Assert.IsNotNull(mapping.Properties.ContainsKey(fieldName)); }
public void CreateIndexMultiFieldMap() { var client = this._client; var typeMapping = new RootObjectMapping(); typeMapping.Name = Guid.NewGuid().ToString("n"); var property = new MultiFieldMapping(); var primaryField = new StringMapping() { Index = FieldIndexOption.not_analyzed }; var analyzedField = new StringMapping() { Index = FieldIndexOption.analyzed }; property.Fields.Add("name", primaryField); property.Fields.Add("name_analyzed", analyzedField); typeMapping.Properties = typeMapping.Properties ?? new Dictionary<string, IElasticType>(); typeMapping.Properties.Add("name", property); var settings = new IndexSettings(); settings.Mappings.Add(typeMapping); settings.NumberOfReplicas = 1; settings.NumberOfShards = 5; settings.Analysis.Analyzer.Add("snowball", new SnowballAnalyzerSettings { Language = "English" }); var indexName = Guid.NewGuid().ToString(); var response = client.CreateIndex(indexName, settings); Assert.IsTrue(response.IsValid); Assert.IsTrue(response.OK); Assert.IsNotNull(this._client.GetMapping(indexName, typeMapping.Name)); response = client.DeleteIndex(indexName); Assert.IsTrue(response.IsValid); Assert.IsTrue(response.OK); }
public void Visit(StringMapping mapping) { this.PrettyPrint(mapping); }
public void UpdateStringMapping(StringMapping stringMapping) { lvKeys.SelectedItems[0].Text = stringMapping.TextFrom; lvKeys.SelectedItems[0].SubItems[1].Text = stringMapping.TextTo; }
public EditStringMappingDialog(StringMapping stringMapping) => m_stringMapping = stringMapping;
public IUserAction CreateAddStringMappingDialog(StringMapping stringMapping) => new AddStringMappingDialog(stringMapping);
public void PutMapping() { var fieldName = Guid.NewGuid().ToString(); var mapping = this._client.GetMapping<ElasticsearchProject>().Mapping; var property = new StringMapping { Index = FieldIndexOption.not_analyzed }; mapping.Properties.Add(fieldName, property); var response = this._client.Map<ElasticsearchProject>(m=>m.InitializeUsing(mapping)); Assert.IsTrue(response.IsValid, response.ConnectionStatus.ToString()); Assert.IsTrue(response.Acknowledged, response.ConnectionStatus.ToString()); mapping = this._client.GetMapping(gm => gm.Index<ElasticsearchProject>().Type<ElasticsearchProject>()).Mapping; Assert.IsNotNull(mapping.Properties.ContainsKey(fieldName)); }
public void EditStringMapping(StringMapping stringMapping) { m_stringMapping = stringMapping; LoadListViewItems(); LoadSelectedStringMapping(); }
public IUserAction CreateEditStringMappingDialog(StringMapping stringMapping) => new EditStringMappingDialog(stringMapping);
public AddStringMappingDialog(StringMapping stringMapping) => m_stringMapping = stringMapping;
public void PutMapping() { var fieldName = Guid.NewGuid().ToString(); var mapping = this._client.GetMapping<ElasticSearchProject>(); var property = new StringMapping { Index = FieldIndexOption.not_analyzed }; mapping.Properties.Add(fieldName, property); var response = this._client.Map(mapping); Assert.IsTrue(response.IsValid, response.ConnectionStatus.ToString()); Assert.IsTrue(response.OK, response.ConnectionStatus.ToString()); mapping = this._client.GetMapping<ElasticSearchProject>(); Assert.IsNotNull(mapping.Properties.ContainsKey(fieldName)); }
public void AddStringMapping(StringMapping stringMapping) { m_stringMapping = stringMapping; LoadListViewItems(); LoadDefaultStringMapping(); }