Comments (3)
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.
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.
Gave it a try, fixed 👍
Thanks!
from forerunnerdb.
Related Issues (20)
- Clarity about find(); HOT 2
- upsert that resolves to update does not update fields that start with '$' HOT 5
- TypeError: http.IncomingMessage.prototype is not an object or null HOT 6
- Support for $not operator HOT 3
- Interactive Demo HOT 1
- index not used when using query operator
- collection.load is very slow HOT 1
- Loading JSON file into forrunner db file and vice versa ? HOT 8
- Duplicate data when setData and ensureIndex HOT 1
- Adding event listener with an ID does not work HOT 2
- Dropping condition does not remove memory reference
- $replace with new documents?
- How does load work? HOT 2
- using Date query with $gte and $lte operators. HOT 3
- Typescript is outdated HOT 3
- Where can i find the database file?
- Weird query behavior when using elemMatch
- WebWorker import ForerunnerDB
- ⚠️ Web SQL is deprecated
- How to query condition on comparing 2 fields?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forerunnerdb.