Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use TopDocsByField? #2

Open
omercioglu opened this issue Apr 3, 2019 · 0 comments
Open

How to use TopDocsByField? #2

omercioglu opened this issue Apr 3, 2019 · 0 comments

Comments

@omercioglu
Copy link

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))
        }
    }
}```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant