-
Notifications
You must be signed in to change notification settings - Fork 95
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
query on indexed field only returns 29 records #170
Comments
Thank you for the code sample, I can reproduce it, it is a regression brought by 0.7.0. |
thanks! If it's not too much trouble, can you provide a high level overview of how indexes work? I did some tracing through the code but don't have any experience in DB implementations so had some trouble figuring it out. |
Basically, in Genji at least, an index is a key-value store which stores the value you want to index as the key of that store, and It uses the primary key of the associated document as the value of that store. In Genji, each type gets its own separate subtree, as you can see in the implementation of the |
noted that if I change the primary key to TEXT, SELECT on indexed field seems to work as expected. |
out of curiosity, I created a little program that dumps a bbolt db created with Genji storing the following record and DB setup: // Test type
type Test struct {
ID string
Field1 string
Field2 string
}
CREATE TABLE tests (id TEXT PRIMARY KEY NOT NULL);
CREATE INDEX idx_tests_field1 ON tests(field1); And then inserted 10 duplicate values. After dumping, I get the below. So, it appears the index stores everything in the key and does not use the value at all. In the key, the format is Is there any chance of things getting confused if the indexed field value has a 0x1e in it?
|
The problem was caused by the separator used Regarding the binary, you can also use BoltBrowser which is great to analyze databases created by Genji. |
If I run a query on an indexed field where there are 100 duplicate records in the database, I only get 29 results. For a similar field that is not indexed, a query returns the full 100 documents. Is this expected?
Source for test: https://github.com/simpleiot/simpleiot/tree/feature-genji/cmd/genji-test2
output of test:
test source:
The text was updated successfully, but these errors were encountered: