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

Search Results cannot be sorted by a date field #26

Closed
miyachan opened this issue Aug 31, 2021 · 4 comments
Closed

Search Results cannot be sorted by a date field #26

miyachan opened this issue Aug 31, 2021 · 4 comments

Comments

@miyachan
Copy link

Attempting to perform a search where the order_by field is a date leads to an error:

{"data":"Schema error: 'Field \"ts\" is of type I64!=Date'","status":400}

It looks this is because the FieldValue is implied to be i64:

FieldType::Date(_) => {
let out: (Vec<(i64, DocAddress)>, usize) =
order_and_search!(searcher, collector, field, &query, executor)?;
(process_search!(searcher, schema, out.0), out.1)

@miyachan
Copy link
Author

Actual this looks like it might be documentation issue (in tanvity?). According to https://docs.rs/tantivy/0.16.0/tantivy/fastfield/trait.FastValue.html dates cannot be fast fields.

@ChillFish8
Copy link
Collaborator

Date fields are fast fields iirc because they're stored as a i64 timestamp internally, or at least according to the docs so its interesting that this behavour doesnt work.
This might require some seperate testing to see if dates requires some other special handling or not but the behavour seems weird.

@ChillFish8
Copy link
Collaborator

I have an idea of what Could be causing this but I'll rewuire some test later on today, if im right the type magic might be failing us here :(

@ChillFish8
Copy link
Collaborator

Okay, this should be fixed now, this was a consequence of a misleading error due to tantivy not having chrono's serde feature enabled.
The fix has been added to the 0.6.x branch (master) and will be backported to 0.5.1

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

2 participants