solrnetにカスタムIReadOnlyMappingManagerを実装して、solrインデックスレコードを表すドキュメントのプロパティを装飾するために独自の属性タイプを使用できるようにしようとしています。GetFieldsメソッドとGetUniqueKeyメソッドの実装を置き換えるだけでよいので、現在の実装は次のとおりです。
public class CustomMappingManager : AttributesMappingManager
{
public new ICollection<KeyValuePair<PropertyInfo, string>> GetFields(Type type)
{
IEnumerable<KeyValuePair<PropertyInfo, IndexFieldAttribute[]>> mappedProperties = this.GetPropertiesWithAttribute<IndexFieldAttribute>(type);
IEnumerable<KeyValuePair<PropertyInfo, string>> fields = from mapping in mappedProperties
select new KeyValuePair<PropertyInfo, string>(mapping.Key, mapping.Value[0].FieldName ?? mapping.Key.Name);
return new List<KeyValuePair<PropertyInfo, string>>(fields);
}
public new KeyValuePair<PropertyInfo, string> GetUniqueKey(Type type)
{
KeyValuePair<PropertyInfo, string> uniqueKey;
IEnumerable<KeyValuePair<PropertyInfo, IndexUniqueKeyAttribute[]>> mappedProperties = this.GetPropertiesWithAttribute<IndexUniqueKeyAttribute>(type);
IEnumerable<KeyValuePair<PropertyInfo, string>> fields = from mapping in mappedProperties
select new KeyValuePair<PropertyInfo, string>(mapping.Key, mapping.Value[0].FieldName ?? mapping.Key.Name);
uniqueKey = fields.FirstOrDefault();
return uniqueKey;
}
}
このタイプは、structuremapを使用して正常に接続されており、ISolrOperationsの具体的なインスタンスのmappingManagerは、このCustomMappingManagerタイプのインスタンスです。
実際の作業を行うsolrnet実装のViistorsまでスタックトレースをたどりました。これらには、意図したとおりにCustomMappingManagerインスタンスがあります。残念ながら、このタイプのGetFieldsメソッドとGetUniqueKeyメソッドは呼び出されず、ドキュメントは常に空になります。
どんなアイデアでも大歓迎です。