Giter VIP home page Giter VIP logo

Comments (3)

fulmicoton avatar fulmicoton commented on June 8, 2024

https://gist.github.com/mmastrac/a06dddbdc2734bde74764edae7418333

from tantivy.

fulmicoton avatar fulmicoton commented on June 8, 2024

confirmed as a bug

from tantivy.

PSeitz avatar PSeitz commented on June 8, 2024

Thanks for the report!
For better performance, we try to convert the users value to the value space of the fast field when running get_docids_for_value_range . With GCD, the value space gets smaller. e.g. [0, 100, 200] is mapped to [0,1,2]. We cannot map a incoming user value of 50 to that user space exactly.

Currently inverse mapping is executed self.monotonic_mapping.inverse(50), which returns 0. Instead we need to detect that we are outside the value space and map to the closest next value. +1 for the start of the range, and -1 for the end of the range

Minimal Example

#[test]
fn test_gcd_bug_regression_1757() {
    let mut schema_builder = Schema::builder();
    let num_field = schema_builder.add_u64_field("url_norm_hash", FAST | INDEXED);
    let schema = schema_builder.build();
    let index = Index::create_in_ram(schema);
    {
        let mut writer = index.writer_for_tests().unwrap();
        writer
            .add_document(doc! {
                num_field => 100u64,
            })
            .unwrap();
        writer
            .add_document(doc! {
                num_field => 200u64,
            })
            .unwrap();
        writer.commit().unwrap();
    }

    let reader = index.reader().unwrap();
    let searcher = reader.searcher();
    let segment = &searcher.segment_readers()[0];
    let field = segment.fast_fields().u64(num_field).unwrap();
    let mut vec = vec![];
    field.get_docids_for_value_range(150..=150, 0..u32::MAX, &mut vec);
    assert_eq!(vec.len(), 0);
}

Buggy Code

This part of the code needs to be able to handle user data

fn get_docids_for_value_range(
    &self,
    range: RangeInclusive<Output>,
    doc_id_range: Range<u32>,
    positions: &mut Vec<u32>,
) {
    self.from_column.get_docids_for_value_range(
        self.monotonic_mapping.inverse(range.start().clone())
            ..=self.monotonic_mapping.inverse(range.end().clone()),
        doc_id_range,
        positions,
    )
}

from tantivy.

Related Issues (20)

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.