Comments (4)
Hi @stefanobranco,
- 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).
- I will bring back the parameterless
MatchAll()
. This one somehow got lost in the refactoring process 🙂 - 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 aHighlightFieldDescriptor
with your default values instead ofHighlightField
:
private HighlightFieldDescriptor HighlightField = new().PreTags(...).PostTags(...);
.Highlight(h => h.Fields(fs => fs.Add(new Field("field"), HighlightField)))
from elasticsearch-net.
.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.
Hi @flobernd!
Thanks for the quick response.
- 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)})))
- I will bring back the parameterless
MatchAll()
. This one somehow got lost in the refactoring process 🙂
Perfect, I figured this was just an oversight
- 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 aHighlightFieldDescriptor
with your default values instead ofHighlightField
:
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.
.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)
- Queries are no longer derive from SearchQuery HOT 4
- Make it easy to log elastic requests HOT 3
- DefaultMappingFor IndexName is not respected in searches HOT 3
- Different classes between filters and return document HOT 3
- can't created repository,response request body missing HOT 4
- Elasticsearch health is accessible but .net client fails HOT 3
- Migration issues Templates and Dynamic queries HOT 5
- Client cannot deserialize string to list of strings HOT 4
- [Feature] Elastic 8 - MatchAll won't accept passing nothing HOT 1
- Creating a local stack s3 repository failed. use Postman works, but code calls are not working.
- [FEATURE] Elastic 8 Client - Stores Enums as Strings HOT 5
- Cannot use RawJsonQuery HOT 6
- Encountered an unsupported variant tag '' on 'Analysis.INormalizer', which could not be deserialized
- Simplify IndexAsync Abstraction to Infer Index Name from TDocument Type HOT 3
- Lacks the ability to put aggregations into aggregations HOT 5
- Elasticsearch 8.13 documentation not available when NuGet update is available HOT 1
- Deserializing type hierarchies doesn't seem to work HOT 10
- Update index settings with PutSettingsAsync fails with error status code 400: "request body is required" HOT 1
- Failing to deserialize response for `GetIndexAsync` HOT 5
- Cannot retrieve mapping of index with `icu_collation_keyword` field HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-net.