NEST 1.0 - What is the new .MapFromAttributes()?
See original GitHub issueI have some POCOs that’re decorated with attributes. Inside they look like this:
[Serializable]
[ElasticType(DisableAllField = true, IdProperty = ElasticsearchFields.FullUncPath)]
public class ShareDriveDocument
{
[ElasticProperty(Name = ElasticsearchFields.Id, Type = FieldType.string_type, Store = true, Index = FieldIndexOption.not_analyzed)]
public string Id { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.FullUncPath, Type = FieldType.string_type, Store = true, Index = FieldIndexOption.not_analyzed)]
public string FullUncPath { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.FileName, Type = FieldType.string_type, Store = true, Index = FieldIndexOption.not_analyzed)]
public string FileName { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.ParentDirectory, Type = FieldType.string_type, Store = true, Index = FieldIndexOption.not_analyzed)]
public string ParentDirectory { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.DateCreated, Type = FieldType.date_type, Store = true, DateFormat = ElasticsearchDateFormats.NoMillis)]
public DateTime DateCreated { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.DateModified, Type = FieldType.date_type, Store = true, DateFormat = ElasticsearchDateFormats.NoMillis)]
public DateTime DateModified { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.SemanticFulltext, Type = FieldType.string_type, Store = true, IndexAnalyzer = "english")]
public string SemanticFulltext { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.ExactFulltext, Type = FieldType.string_type, Store = true, IndexAnalyzer = "not_analyzed")]
public string ExactFulltext { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.OriginalSize, Type = FieldType.long_type, Store = true)]
public long OriginalFileSize { get; internal set; }
[ElasticProperty(Name = ElasticsearchFields.TextSize, Type = FieldType.long_type, Store = true)]
public long TextContentSize { get; internal set; }
public ShareDriveDocument(IndexingJob indexingJob, string fulltext)
{
var fileInfo = new FileInfo(indexingJob.PathName);
FullUncPath = indexingJob.PathName;
FileName = Path.GetFileName(indexingJob.PathName);
ParentDirectory = Path.GetDirectoryName(indexingJob.PathName);
DateModified = fileInfo.LastWriteTimeUtc;
DateCreated = fileInfo.CreationTimeUtc;
SemanticFulltext = fulltext;
ExactFulltext = fulltext;
OriginalFileSize = fileInfo.Length;
TextContentSize = fulltext.Length;
}
//...
}
Once upon a time, I could do this:
var client = new ElasticClient(connectionSettings);
//...
client.MapFromAttributes<ElasticsearchDocument>(TEST_INDEX, type);
But I can’t anymore. client.Map<ShareDriveDocument>(m => m.MapFromAttributes());
triggers a runtime error. I suspect this is because m.MapFromAttributes() is a 0.12.* thing.
How do I accomplish this in 1.0?
Issue Analytics
- State:
- Created 9 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Breaking Changes | Elasticsearch.Net and NEST
This page describes breaking changes NEST introduces in its 1.0 release and to an extend how you should handle ... Removed MapFromAttributes()edit.
Read more >How can I use nested types with NEST client for Elastic ...
The client.MapFromAttributes() is very limited and will probably be removed in the 1.0 release. Its great to annotate property names but quickly ...
Read more >Chapter 2. Basic Operations
The inline implementation of AttributesMapper just gets the desired attribute value from the Attributes and returns it. Internally, LdapTemplate iterates over ...
Read more >C# (CSharp) Nest ElasticClient.Index Examples
These are the top rated real world C# (CSharp) examples of Nest. ... MapFromAttributes())); // Add some people var jp = new Person...
Read more >How to connect LDAP server using Spring framework ? or ...
In the following post we will look in to. How to connect LDAP server using Spring framework; Simplify directory access with Spring LDAP ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nasreekar I’ve opened #2085 to better handle attachments.
@nasreekar Take a look at the NEST 2.x documentation, specifically the documentation on Automapping and on breaking changes between 1.x and 2.x.