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)
- Failing to deserialize response for `GetIndexAsync` HOT 5
- Cannot retrieve mapping of index with `icu_collation_keyword` field HOT 6
- cannot instantiate new DynamicTemplate when creating index. HOT 4
- Default index is not used in query with 8.13.15 client HOT 1
- Missing properties in aggregation API HOT 3
- Improve documentation for error handling
- Elastic.Transport.UnexpectedTransportException when calling elasticClient.MachineLearning.InferTrainedModelAsync HOT 1
- Support for using input_output option in inference processor
- CI: Automate reference documentation
- Intervals query is missing the option to set Field HOT 3
- Fluent API for composite aggregation sources
- IndexSettingsConverter tries to deserialize routing_path as collection of string even if there is a string in raw JSON response HOT 1
- ESQL Arrow support
- Implement Connectors API
- Add back TermsRangeQuery in the Elasticsearch .Net Client HOT 1
- error in elastic client when trying to get the mappings HOT 5
- Cannot run knn query using elasticClient.RequestResponseSerializer HOT 4
- Improve usability of `FiltersAggregation`
- Adding document to Elastic with Client.IndexAsync doesn't await result; also ambigious function parameters HOT 7
- ElasticsearchClient.Indicies.GetAsync throws UnexpectedTransportException
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.