Home > database >  How to prevent prefixes on Nest aggregations
How to prevent prefixes on Nest aggregations

Time:11-07

It looks like Nest is somehow applying a prefix to the names of my aggregations, which can be seen on the raw JSON response back from Elastic Search (seen via DisableDirectStreaming). Specifically, these prefixes are sterms#, dterms#, and range#. These are seemingly dependant on how the aggregation in particular was made (string term, double/decimal term and range term).

I ran the same query that Nest produced, manually in Postman against ES, and it returned the aggregations without the prefixes, so I'm guessing this is as a result of a Nest specific configuration somewhere.

I would like to remove these via configuration rather than a string replace. I do not see these in the documentation so would appreciate some guidance on how to prevent these prefixes on the response object.

CodePudding user response:

So Elastic calls these typed keys. You can find more information on them here.

To prevent the prefixes, you can set the TypedKeys property to false on the SearchRequest. This is not particularly well documented. This may cause adverse effects on Nest's ability to Deserialise the aggregations, so use with caution.

  • Related