strangerlabs / tantivy

Node.js bindings to Tantivy Search
MIT License
12 stars 2 forks source link

How to use TopDocsByField? #2

Open omercioglu opened 5 years ago

omercioglu commented 5 years ago

Hi, I want to use TopDocsByField and i have created a module by copying the "native/src/js_top_docs/mod.rs". I'm getting the error on the Ok() line; expected struct 'tantiny::collector::TopDocs', found struct 'tantiny::collector::TopDocsByField'. How to fix this an continue? (BTW: I'm just starting to learn Rust)


extern crate tantivy;

use neon::prelude::*;
use tantivy::collector::TopDocs;

declare_types! {
    pub class JsTopDocsByField for TopDocs {
        init(mut cx) {
            let n_docs = cx.argument::<JsNumber>(0)?.value() as usize;
            let order_by_field = cx.argument::<JsString>(1)?.value();
            Ok(TopDocs::with_limit(n_docs).order_by_field(sort_by_field))
        }
    }
}```