public void CreateIndexSettingsAndMappingsForDocument(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers, EntityContextInfo entityInfo, MappingDefinition mappingDefinition) { if (_processedItems.Contains("_index" + index)) { return; } _processedItems.Add("_index" + index); var elasticCrudJsonWriter = new ElasticJsonWriter(); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); CreateIndexSettings(elasticCrudJsonWriter, indexSettings); indexAliases.WriteJson(elasticCrudJsonWriter); indexWarmers.WriteJson(elasticCrudJsonWriter); IndexSettingsCreatePropertyMappingForTopDocument(entityInfo, mappingDefinition, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); CreateIndexCommand(elasticCrudJsonWriter.GetJsonString(), index); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("limit"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("value", _limit, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("prefix"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue(_field, _prefix, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WriteStartArray(); elasticCrudJsonWriter.JsonWriter.WriteValue(Longitude); elasticCrudJsonWriter.JsonWriter.WriteValue(Latitude); elasticCrudJsonWriter.JsonWriter.WriteEndArray(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("exists"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("field", _field, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("order"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue(_field, _order.ToString(), elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("type", DefaultGeoShapes.Point, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WritePropertyName("coordinates"); Coordinates.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
private void CreateParentMappingForDocument(ElasticJsonWriter elasticCrudJsonWriter, string parentType) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("_parent"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName("type"); elasticCrudJsonWriter.JsonWriter.WriteValue(parentType); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
/// <summary> /// "_routing": { "required": true }, /// </summary> /// <param name="elasticCrudJsonWriter"></param> private void CreateForceRoutingMappingForDocument(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("_routing"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName("required"); elasticCrudJsonWriter.JsonWriter.WriteValue("true"); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public override void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("key", KeyValue, elasticCrudJsonWriter, KeySet); elasticCrudJsonWriter.JsonWriter.WritePropertyName("from"); elasticCrudJsonWriter.JsonWriter.WriteValue(_value); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
private void WriteValues(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("random_score"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("seed", _seed, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("or"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); WriteOrFilterList(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
/// "settings" : { "number_of_shards" : 1 }, private void CreateIndexSettings(ElasticJsonWriter elasticCrudJsonWriter, IndexSettings indexSettings) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("settings"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); indexSettings.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("term"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue(_term, _termValue, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public static void WriteValue(string key, object valueObj, ElasticJsonWriter elasticCrudJsonWriter, bool writeValue = true) { if (writeValue) { elasticCrudJsonWriter.JsonWriter.WritePropertyName(key); elasticCrudJsonWriter.JsonWriter.WriteValue(valueObj); } }
private void ProccessPropertyMappingsWithoutTypeName(ElasticJsonWriter elasticCrudJsonWriter, EntityContextInfo entityInfo, ElasticMapping elasticMapping) { //"properties": { elasticCrudJsonWriter.JsonWriter.WritePropertyName("properties"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticMapping.MapEntityValues(entityInfo, elasticCrudJsonWriter, true, CreatePropertyMappings); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
//"aliases" : { // "april_2014" : {}, // "year_2014" : {} //}, public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("aliases"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); foreach (var alias in Aliases) { alias.WriteJson(elasticCrudJsonWriter); } elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("geohash_cell"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName(_field); _location.WriteJson(elasticCrudJsonWriter); JsonHelper.WriteValue("precision", _precision, elasticCrudJsonWriter); JsonHelper.WriteValue("neighbors", _neighbors, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("warmers"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); foreach (var warmer in Warmers) { warmer.WriteJson(elasticCrudJsonWriter); } elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("fquery"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName("query"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); _query.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public virtual void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("analysis"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); Tokenizers.WriteJson(elasticCrudJsonWriter); Filters.WriteJson(elasticCrudJsonWriter); CharFilters.WriteJson(elasticCrudJsonWriter); Analyzer.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("type", DefaultGeoShapes.Envelope, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WritePropertyName("coordinates"); elasticCrudJsonWriter.JsonWriter.WriteStartArray(); foreach (var item in Coordinates) { item.WriteJson(elasticCrudJsonWriter); } elasticCrudJsonWriter.JsonWriter.WriteEndArray(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("span_multi"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName("match"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); _query.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
protected virtual void WriteJsonBase(ElasticJsonWriter elasticCrudJsonWriter, Action <ElasticJsonWriter> writeFilterSpecific) { if (AnalyzerSet) { elasticCrudJsonWriter.JsonWriter.WritePropertyName(Name); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); writeFilterSpecific.Invoke(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); } }
//{ // "query" : { // "match" : { // "name" : { // "query" : "group" // } // } // } //} public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("match"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName(_field); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); WriteBasePropertiesJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void WriteJson(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("type", DefaultGeoShapes.GeometryCollection, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WritePropertyName("geometries"); elasticCrudJsonWriter.JsonWriter.WriteStartArray(); foreach (var item in Geometries) { (item as IGeoType).WriteJson(elasticCrudJsonWriter); } elasticCrudJsonWriter.JsonWriter.WriteEndArray(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
public void UpdateSettings(string index, IndexUpdateSettings indexUpdateSettings) { var elasticCrudJsonWriter = new ElasticJsonWriter(); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName("index"); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); indexUpdateSettings.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); SettingsCommand(elasticCrudJsonWriter.GetJsonString(), index); }
/// <summary> /// Create a new mapping for the child type in the parent document index /// </summary> /// <param name="entityInfo"> </param> /// <param name="elasticMapping"> </param> /// <param name="item"> </param> /// <param name="mappingDefinition"> definition for the type mappings </param> private void CreatePropertyMappingForChildDocument(EntityContextInfo entityInfo, ElasticMapping elasticMapping, EntityContextInfo item, MappingDefinition mappingDefinition) { var childMapping = _elasticSerializerConfiguration.ElasticMappingResolver.GetElasticSearchMapping(item.EntityType); var parentMapping = _elasticSerializerConfiguration.ElasticMappingResolver.GetElasticSearchMapping(item.ParentEntityType); var childType = childMapping.GetDocumentType(item.EntityType); var parentType = parentMapping.GetDocumentType(item.ParentEntityType); var processedId = childType + "_" + parentType; if (_processedItems.Contains(childType)) { var test = CommandTypes.Find(t => t.StartsWith(childType)); if (test != processedId) { throw new ElasticException("InitMappings: Not supported, child documents can only have one parent"); } return; } _processedItems.Add(childType); CommandTypes.Add(processedId); var elasticCrudJsonWriter = new ElasticJsonWriter(); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); elasticCrudJsonWriter.JsonWriter.WritePropertyName(childType); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); mappingDefinition.Source.WriteJson(elasticCrudJsonWriter); mappingDefinition.All.WriteJson(elasticCrudJsonWriter); CreateParentMappingForDocument( elasticCrudJsonWriter, elasticMapping.GetDocumentType(item.ParentEntityType)); if (item.RoutingDefinition.RoutingId != null && _elasticSerializerConfiguration.UserDefinedRouting) { CreateForceRoutingMappingForDocument(elasticCrudJsonWriter); } ProccessPropertyMappingsWithoutTypeName(elasticCrudJsonWriter, item, childMapping); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); CreateMappingCommandForTypeWithExistingIndex(elasticCrudJsonWriter.GetJsonString(), elasticMapping.GetIndexForType(entityInfo.EntityType), childMapping.GetDocumentType(item.EntityType)); }
protected void WriteInternalJson(ElasticJsonWriter elasticCrudJsonWriter, AliasAction aliasAction, Action <ElasticJsonWriter> writeFilterSpecific = null) { elasticCrudJsonWriter.JsonWriter.WritePropertyName(aliasAction.ToString()); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); JsonHelper.WriteValue("index", _index, elasticCrudJsonWriter); JsonHelper.WriteValue("alias", _alias, elasticCrudJsonWriter); if (writeFilterSpecific != null) { writeFilterSpecific.Invoke(elasticCrudJsonWriter); } elasticCrudJsonWriter.JsonWriter.WriteEndObject(); }
private void WriteOrFilterList(ElasticJsonWriter elasticCrudJsonWriter) { elasticCrudJsonWriter.JsonWriter.WritePropertyName("filters"); elasticCrudJsonWriter.JsonWriter.WriteStartArray(); foreach (var or in _or) { elasticCrudJsonWriter.JsonWriter.WriteStartObject(); or.WriteJson(elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); } elasticCrudJsonWriter.JsonWriter.WriteEndArray(); }