benashford / rs-es Goto Github PK
View Code? Open in Web Editor NEWA Rust client for the ElasticSearch REST API
License: Apache License 2.0
A Rust client for the ElasticSearch REST API
License: Apache License 2.0
There's a big gap in testing around Aggregations generally, and the more exotic aggregations specifically.
And also check sorting options are consistent across the board.
There are a lot of macros defined in .../aggregations/bucket.rs
, many of which could be simple functions.
e.g. use query_then_fetch
to 0
Investigate and fix...
Code
use rs_es::Client;
use rs_es::operations::search::{Sort, SortField, Order};
use rs_es::query::{Filter, Query};
// [...]
fn main() {
// [...]
// I'm just trying to compile this, it's the snippet inside the README
let query = Query::build_filtered(
Filter::build_bool()
.with_must(vec![
Filter::build_term("field_a", "value").build(),
Filter::build_range("field_b")
.with_gte(5)
.with_lt(10)
.build()
])
)
.with_query(Query::build_query_string("some value").build())
.build();
let result = es.search_query()
.with_indexes(ES_INDEXES)
//.with_query(&Query::build_match_all().build())
.with_query(&query)
.with_sort(&Sort::new(vec![
SortField::new("updated_at", Some(Order::Desc)).build()
]))
.send()
.ok()
.unwrap();
}
Error
src/main.rs:26:15: 26:36 error: the trait
core::convert::From<rs_es::query::BoolFilter>
is not implemented for the typeBox<rs_es::query::Filter>
[E0277]
src/main.rs:26 let query = Query::build_filtered(
^~~~~~~~~~~~~~~~~~~~~
src/main.rs:26:15: 26:36 help: runrustc --explain E0277
to see a detailed explanation
src/main.rs:26:15: 26:36 note: required byrs_es::query::Query::build_filtered
error: aborting due to previous error
Could not compilesample
.Caused by:
Process didn't exit successfully:rustc src/main.rs --crate-name sample --crate-type bin -g --out-dir /Users/giovanni/Desktop/sample/target/debug --emit=dep-info,link -L dependency=/Users/giovanni/Desktop/sample/target/debug -L dependency=/Users/giovanni/Desktop/sample/target/debug/deps --extern postgres=/Users/giovanni/Desktop/sample/target/debug/deps/libpostgres-2680c17c75628e6e.rlib --extern rustc_serialize=/Users/giovanni/Desktop/sample/target/debug/deps/librustc_serialize-79a17eda1cd94e46.rlib --extern rs_es=/Users/giovanni/Desktop/sample/target/debug/deps/librs_es-5ee9d634caeceacd.rlib --extern postgres_array=/Users/giovanni/Desktop/sample/target/debug/deps/libpostgres_array-06c7843d8da23f1e.rlib -L native=/Users/giovanni/Desktop/sample/target/debug/build/openssl-09576f2f9776fa80/out -L native=/Users/giovanni/Desktop/sample/target/debug/build/openssl-sys-extras-52d5315fb71d3c6d/out
(exit code: 101)
Platform
Machine
Darwin lifestream.Speedport_W723_V_Typ_A_1_01_011 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
ES
Version: 2.1.1, Build: 40e2c53/2015-12-15T13:05:55Z, JVM: 1.8.0_66
Rust
rustc 1.6.0
rs-es
Both 0.2 and master
Specific tests would be useful for Geo queries
The documentation implies it is an experimental feature, so it may be best to wait until it stabilises.
At present we need an owned String for error messages, which is cumbersome in trivial examples where &'static str
could do.
Serde is being pitched as the replacement for rustc_serialize.
Should be done after #19 as that is likely to produce a re-usable core for the query.
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html
please take a look at serde-deprecated/quasi#35 (comment) i've exacly the same problem, but couldn't solve this by using
[dependencies.rs-es]
version = "0.3.2"
features = ["nightly_without_ssl"]
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
If a way can be found to implement in a way that's compatible with idiomatic Rust.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html
(documentation doesn't explain what is returned, so some exploration will be required)
Do you have plans to support Elasticsearch 2.x? There are a bunch of changes, but it'd be good to be able to run against the latest version.
There's a number of API's in this category: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html
The utility of them is not obvious, however.
The Nightly Travis build is currently disabled due to an issue with an upstream dependency (Serde, in particular Quasi) being built on Nightly.
We should upgrade the dependency as soon as a fix is available, and re-enable the nightly build.
ElasticSearch can return objects from different types in a query. I think it's perfect to represent this with a Rust enum but I don't see how to manage this with rs-es
๐
with json it might be a bit clearer.
let's take a elastic search query returning 2 results, each of a different type:
{
"_shards": {
...
},
"hits": {
"hits": [
{
"_id": "AVQQZtpeUZ0aRT9bKks0",
"_index": "my_index",
"_score": 1.3870806,
"_source": {
"name": "toto"
},
"_type": "FirstType"
},
{
"_id": "AVQQZtfmUZ0aRT9bKiL6",
"_index": "my_index",
"_score": 1.3752246,
"_source": {
"age": 12
},
"_type": "SecondType"
}
]
}
}
I would like to represent this in rs-es
with
struct FirstType {
name: String
}
struct SecondType {
age: i32
}
enum Document {
FirstType(FirstType),
SecondType(SecondType)
}
and the es result would be SearchResult<Document>
The serde serialization could use the elastic search _type
field to build the right type.
The problem is that this _type
field is at the same level as the _source
field, so it is not available when defining the serialization of Document
.
I thus don't see a way to handle this apart from handling it directly in rs-es
(and I'm not sure to see how to do this ๐ ).
Do you see an easy way to do this ? I'm willing to implement it but I don't see a clean and non api-breaking way to do this.
Currently the errors returned from any function that returns a Result
are all EsError
. There are five varieties of these depending on whether the error was generated: 1) internally within rs-es
, 2) by ElasticSearch itself, 3) from the HTTP library, 4) miscellaneous IO errors, and 5) JSON encoding/decoding errors.
In particular server-side errors can convey a lot of useful information. Rather than converting to a String we should considering parsing the JSON response and making that available.
Hello,
I was wondering how I can set an index for a certain field. Basically I have an array of strings work_roles
that appears in the following way
"work_roles": {
"type": "string"
}
and my goal is to make it in this way:
"work_roles": {
"type": "string",
"index": "not_analyzed"
}
Unfortunately I wasn't able to find anything in the docs. Am I missing something?
I guess it should be something like this.
A number of queries are not yet implemented. We should implement the full set.
The Sort By Script option when searching, the Function query, and scripted aggregations all have a concept of a script. These appear to be mostly similar in terms of options and generated JSON. We should de-duplicate these implementations as they may make as-yet-to-be-implemented queries easier to implement.
See also: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_scripting_changes.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.