Comments (3)
The values that guided the choice make sense to me.
A default index is not a thing that we're interested in. We're looking for a more dynamic approach. But thanks anyway.
👍
By the way, once we have an implicit operator from IndexName and Id to string, we no longer need the overload with string; it's not gonna work anyway:
I would rather say it works too good 😄 Both IndexName
and Id
have implicit conversion operators from string
. This unfortunately causes an ambiguity for which I have not yet decided how to solve it.
As a workaround you can either cast to e.g. IndexName
like you did above, or specify the argument name explicitly:
=> client.IndexAsync(document, index: "index-name", token);
from elasticsearch-net.
Hi @AntonioFalcaoJr,
thanks for the feature request. What version of the Elasticsearch client are you currently using? I'm asking because there already is an IndexAsync
overload in the ElasticsearchClient
that supports index name inference:
public virtual Task<IndexResponse> IndexAsync<TDocument>(TDocument document, CancellationToken cancellationToken = default)
To use this method, you must specify the desired default index during initialization like this:
var settings = new ElasticsearchClientSettings(new Uri("https://..."))
.Authentication(new BasicAuthentication("elastic", "..."))
.DefaultMappingFor<Person>(x => x.IndexName("person")); // <- Set default index for 'Person'
var client = new ElasticsearchClient(settings);
await client.IndexAsync(new Person());
The implicit derivation of a lowercase index name from a specific type is problematic. We try to follow the principle of "explicit before implicit" to avoid as many surprises as possible. Not everyone uses an index name that is simply a lowercase representation of the entity name. Also, sometimes the same entity is stored in different indexes. For this reason, we want the user to explicitly configure the default index once during initialization.
Please let me know if that works for you 🙂
from elasticsearch-net.
I'm using version 8.13.12
.
The values that guided the choice make sense to me.
A default index is not a thing that we're interested in. We're looking for a more dynamic approach. But thanks anyway.
By the way, once we have an implicit operator from IndexName and Id to string, we no longer need the overload with string; it's not gonna work anyway:
from elasticsearch-net.
Related Issues (20)
- Property type and name attribute HOT 1
- Using the Text property in a TermSuggester or PhraseSuggester results in a parsing exception HOT 3
- Any example of doing Join with .Net Client? HOT 8
- UpdateByQuery Slices property is not creating right request querystring parameter HOT 3
- Elastic.Transport.UnexpectedTransportException when using GetMappingAsync and dynamic_templates HOT 5
- Global Aggregations in elastic search client version 8.13 HOT 6
- When using Bool Filter to query, the relationship between Term and Range is not 'And', which is inconsistent with the native DSL query results HOT 2
- 8.15.6 - Bring back Aggregation LocalMetadata HOT 2
- 8.15.6 - Make public SortOptions.AdditionalPropertyName HOT 2
- 8.15.6 - Bring Back IProperty.Name HOT 2
- 8.15.6 - IPropertyWithClrOrigin replacements?
- 8.15.6 - ExtendedBounds -> ExtendedBoundsDate needs implicit convertors for anchored DateTime HOT 2
- 8.15.6 - General API Feedback while upgrading from NEST. HOT 2
- SearchResponse.Documents throws null reference exception on successful call
- Fluent API Documentation missing
- Feature request to add back || and &&. Or to allow for dynamic building and joining of queries HOT 3
- Feature request to publish JsonNetSerializer HOT 1
- 8.15.6 - Term/Terms Filtering feedback HOT 1
- 8.15.6 - TermQuery / TermsQuery inconsistencies and feedback HOT 6
- 8.15.6: TypeMappingDescriptor Dynamic Feedback 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.