public override void AddField(string fieldName, object fieldValue, bool append = false) { AbstractSearchFieldConfiguration fieldConfiguration = this.Context.Index.Configuration.FieldMap.GetFieldConfiguration(fieldName); string fieldName1 = fieldName; fieldName = this.Index.FieldNameTranslator.GetIndexFieldName(fieldName); AzureSearchFieldConfiguration fieldSettings = this.Index.Configuration.FieldMap.GetFieldConfiguration(fieldName) as AzureSearchFieldConfiguration; if (fieldSettings != null) { if (fieldConfiguration != null) { fieldValue = fieldConfiguration.FormatForWriting(fieldValue); } this.AddField(fieldName, fieldValue, fieldSettings, 0.0f); } else { if (VerboseLogging.Enabled) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("Field: {0} (Adding field with no field configuration)" + Environment.NewLine, (object)fieldName); stringBuilder.AppendFormat(" - value: {0}" + Environment.NewLine, fieldValue != null ? (object)fieldValue.GetType().ToString() : (object)"NULL"); stringBuilder.AppendFormat(" - value: {0}" + Environment.NewLine, fieldValue); VerboseLogging.CrawlingLogDebug(new Func <string>(((object)stringBuilder).ToString)); } IEnumerable enumerable = fieldValue as IEnumerable; if (enumerable != null && !(fieldValue is string)) { foreach (object obj in enumerable) { object valueToIndex = this.Index.Configuration.IndexFieldStorageValueFormatter.FormatValueForIndexStorage(obj, fieldName1); if (fieldConfiguration != null) { valueToIndex = fieldConfiguration.FormatForWriting(valueToIndex); } if (valueToIndex != null) { this.fields.Enqueue((Field) new Field(fieldName, valueToIndex.ToString())); } } } else { object valueToIndex = this.Index.Configuration.IndexFieldStorageValueFormatter.FormatValueForIndexStorage(fieldValue, fieldName1); if (fieldConfiguration != null) { valueToIndex = fieldConfiguration.FormatForWriting(valueToIndex); } if (valueToIndex == null) { return; } //TODO: How to figure out setting field value this.fields.Enqueue((Field) new Field(fieldName, DataType.String /*, valueToIndex.ToString()*/)); } } }
public override void AddField(IIndexableDataField field) { AbstractSearchFieldConfiguration fieldConfiguration1 = this.Context.Index.Configuration.FieldMap.GetFieldConfiguration(field); object fieldValue = this.Index.Configuration.FieldReaders.GetFieldValue(field); string name = field.Name; AzureSearchFieldConfiguration fieldSettings = this.Index.Configuration.FieldMap.GetFieldConfiguration(field) as AzureSearchFieldConfiguration; if (fieldSettings == null) { VerboseLogging.CrawlingLogDebug((Func <string>)(() => string.Format("Cannot resolve field settings for field id:{0}, name:{1}, typeKey:{2} - The field will not be added to the index.", field.Id, (object)field.Name, (object)field.TypeKey))); } else { object obj = fieldConfiguration1.FormatForWriting(fieldValue); float boost = BoostingManager.ResolveFieldBoosting(field); if (IndexOperationsHelper.IsTextField(field)) { AzureSearchFieldConfiguration fieldConfiguration2 = this.Index.Configuration.FieldMap.GetFieldConfiguration("_content") as AzureSearchFieldConfiguration; this.AddField("_content", obj, fieldConfiguration2 ?? this.defaultTextField, 0.0f); } this.AddField(name, obj, fieldSettings, boost); } }