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: how to add properties to objects for indexing?

See original GitHub issue

Serilog sink for Elasticsearch defines a class LogEvent, fills its properties and sends it for indexing. This class has several top level scalar properties, but the most interesting part is the dictionary (name to value) of dynamic properties, which is declared like this:

    [JsonProperty(PropertyName = "fields")]
    public IDictionary<string, object> Properties { get; set; }

If there are dynamic properties “One” and “Two” what I get in Elasticsearch is “fields.One” and “fields.Two”.

The big question is how to get rid of “fields” prefix?? I want dynamic properties to be added at the top level and be accessible without any prefix, the same way as scalar properties of the class are.

I keep banging my head against the wall, but cannot figure how to do it. Could you help please?

Thank you! Konstantin

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
konstecommented, Oct 2, 2014

Greg, I finally found one line solution! Just put [JsonExtensionData] attribute on the Dictionary<string, object> and desired behavior is achieved automagically!

Konstantin

0reactions
konstecommented, Sep 25, 2014

Thank you, Greg! Sure, I will give it a try shortly!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elasticsearch NEST add property to existing index
I would like to add a new property to an existing index that already contains documents. var client = new ElasticClient(settings); var ...
Read more >
ES NEST - How to Create an index and Bulk ...
Hi, guys! I have a Dataset for which I don't know or have the type in advance, nor the number of properties or...
Read more >
Indexing documents with the NEST Elasticsearch .NET client
There are a number of ways you can index documents into Elasticsearch using the NEST Elasticsearch .NET client.
Read more >
Elasticsearch Mapping: The Basics, Updates & Examples
Within a search engine, mapping defines how a document is indexed and how it indexes and stores its fields. We can compare mapping...
Read more >
How Can I Add a Key-Value Pair to a JavaScript Object?
You can add multiple properties at once or merge multiple iterables, such as objects. The merge is shallow: Any nested objects will not...
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