Giter VIP home page Giter VIP logo

Comments (3)

Irrelon avatar Irrelon commented on July 23, 2024

This is caused by the way the query analyser determines if an index should be used or not based on the keys being queried. At present indexes are simply hash maps with a hash built from the keys that are indexed so a collection with an index on business_id and business_name will have a hash that concatenates those values from the object being indexed e.g.

{ business_id: '1', business_name: 'apple' }

Would produce an index with a hash map like this:

{
    "1_apple":[{
        business_id: '1',
        business_name: 'apple'
    }]
}

The index stores the keys that were indexed and when a query is run against the index it will return results based on the hash generated from the keys of the query. The bug is in the analyser because it determines that if at least one key in the query matches the index that it should be used for a quick lookup but that is a false assumption. It would be correct if the index was a tree structure because it could be traversed and data pulled at the point the keys intersect but because the indexes are currently limited to hash maps the hash from the query you specified in your example would be:

"1"

Then a lookup against the map by doing:

return this.hashMap["1"];

Would return no results because the entire hash to bring back the result would have to be used, not a partial e.g. "1_apple" rather than "1".

At present there is a quick fix in that the query analyser can be altered to ensure that it does not use a query where only one of the keys in an index is used. This is not ideal but fixes the bug in that results will actually be returned.

The issue about matching data based on single key queries in a multi-key index can be solved using a tree structure instead of a hash map but that is more of a new feature than a bug fix :)

I'll keep this issue open and update when the bug is resolved shortly.

from forerunnerdb.

Irrelon avatar Irrelon commented on July 23, 2024

Fix to this is in dev branch version 1.3.1 - if you could give it a try and test against your issue that would be great :)

from forerunnerdb.

aabluedragon avatar aabluedragon commented on July 23, 2024

Gave it a try, fixed 👍
Thanks!

from forerunnerdb.

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.