Giter VIP home page Giter VIP logo

Comments (4)

flobernd avatar flobernd commented on June 5, 2024 1

Hi @stefanobranco,

  1. The aggregation change requires a little bit of additional code, but on the same time this new structure maps closely to the corresponding JSON request. This is a good thing as it's consistent now with the REST documentation and as well allowed me to remove a lot of internal hacks that were previously required to support the old strucutre in the .NET client (these hacks caused several issues in the past).
  2. I will bring back the parameterless MatchAll(). This one somehow got lost in the refactoring process 🙂
  3. The HighlightField case I have to check in detail, but it seems like you are mixing up descriptors and class initializer style here. A solution would be to initialize a HighlightFieldDescriptor with your default values instead of HighlightField:
private HighlightFieldDescriptor HighlightField = new().PreTags(...).PostTags(...);

.Highlight(h => h.Fields(fs => fs.Add(new Field("field"), HighlightField)))

from elasticsearch-net.

stijnherreman avatar stijnherreman commented on June 5, 2024 1
.Order(new List<KeyValuePair<Field, SortOrder>>(new []{new KeyValuePair<Field, SortOrder>(Field.CountField, SortOrder.Desc)})))

You don't need the List, and depending on the C# version you can write it like this:

// C# 9
.Order(new KeyValuePair<Field, SortOrder>[] { new(Field.CountField, SortOrder.Desc) })

// C# 12
.Order([new(Field.CountField, SortOrder.Desc)])

from elasticsearch-net.

stefanobranco avatar stefanobranco commented on June 5, 2024

Hi @flobernd!

Thanks for the quick response.

  1. The aggregation change requires a little bit of additional code, but on the same time this new structure maps closely to the corresponding JSON request. This is a good thing as it's consistent now with the REST documentation and as well allowed me to remove a lot of

I figured it was something like that. I guess I find the 'Add' a bit 'unattractive', but that's probably a personal thing and it's completely reasonable as it is. I did notice one more small thing, as I'm trying to now completely move away from our nest client. When ordering aggregations:

Before (Nest):

.Order(o => o.CountDescending())

Now (unless I missed something):

.Order(new List<KeyValuePair<Field, SortOrder>>(new []{new KeyValuePair<Field, SortOrder>(Field.CountField, SortOrder.Desc)})))
  1. I will bring back the parameterless MatchAll(). This one somehow got lost in the refactoring process 🙂

Perfect, I figured this was just an oversight

  1. The HighlightField case I have to check in detail, but it seems like you are mixing up descriptors and class initializer style here. A solution would be to initialize a HighlightFieldDescriptor with your default values instead of HighlightField:

You're right. I'm pretty sure the previous variant did work that way but either way your solution works just as well and is more consistent, so there's probably no need to spend more time on this.

from elasticsearch-net.

stefanobranco avatar stefanobranco commented on June 5, 2024
.Order(new List<KeyValuePair<Field, SortOrder>>(new []{new KeyValuePair<Field, SortOrder>(Field.CountField, SortOrder.Desc)})))

You don't need the List, and depending on the C# version you can write it like this:

// C# 9
.Order(new KeyValuePair<Field, SortOrder>[] { new(Field.CountField, SortOrder.Desc) })

// C# 12
.Order([new(Field.CountField, SortOrder.Desc)])

Hahaha you're right of course, the list is beyond silly here. I guess the C# 12 version is reasonable enough in that case.

from elasticsearch-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.