question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NEST 1.0 - What is the new .MapFromAttributes()?

See original GitHub issue

I 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:closed
  • Created 9 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
russcamcommented, May 10, 2016

@nasreekar I’ve opened #2085 to better handle attachments.

1reaction
russcamcommented, May 5, 2016
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found