Giter Club home page Giter Club logo

rs-es's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rs-es's Issues

the trait core::convert::From<rs_es::query::BoolFilter> is not implemented for the type Box<rs_es::query::Filter>

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 type Box<rs_es::query::Filter> [E0277]
src/main.rs:26 let query = Query::build_filtered(
^~~~~~~~~~~~~~~~~~~~~
src/main.rs:26:15: 26:36 help: run rustc --explain E0277 to see a detailed explanation
src/main.rs:26:15: 26:36 note: required by rs_es::query::Query::build_filtered
error: aborting due to previous error
Could not compile sample.

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

Allow `&'static str` as errors

At present we need an owned String for error messages, which is cumbersome in trivial examples where &'static str could do.

Re-enable Nightly

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.

search query with different result types

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.

Improve error handling

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.

Set an index for a field

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.