Closed DevQps closed 4 years ago
Hi @DevQps
A mapping can be created either upon index creation:
let response = client
.indices()
.create(IndicesCreateParts::Index("test_index"))
.body(json!({
"mappings" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}))
.send()
.await?;
Or by putting a mapping into an existing index (assuming the index does not have a mapping, or if it does, that any of the properties do not conflict with existing properties):
let response = client
.indices()
.put_mapping(IndicesPutMappingParts::Index(&["test_index"]))
.body(json!({
"properties" : {
"field1" : { "type" : "text" }
}
}))
.send()
.await?;
The client API functions and builder structs are generated from a spec, which makes weaving examples into them a little tricky. https://github.com/elastic/elasticsearch-rs/issues/64 will generate rust examples for all the examples in the elastic.co reference documentation, so there will be a dropdown to see what a specific call looks like for the Rust client. Take a look at the match query page on master
as an example. Once these doc examples are implemented, I think we could look at weaving them into docs.rs, tackling the problem more generally.
Thanks for your response!
Please describe the documentation I was browsing the documentation and was unable to find some documentation on how to create a mapping using the API. Maybe it would be nice to provide an example on the
IndicesPutMapping
orput_mapping
functions?Describe where the documentation should for A documented example should be added that shows how to create a mapping on an index.