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

Issues with getAll #135

Open
joques opened this issue Nov 27, 2012 · 13 comments
Open

Issues with getAll #135

joques opened this issue Nov 27, 2012 · 13 comments

Comments

@joques
Copy link

joques commented Nov 27, 2012

Hi all,
I seem to be experiencing this old trouble again with getAll. I made the following call

dbClient.getAll bucketName, {where: criteria}, (error, result) => ...

Obviously, I am expecting result to be an array, where each item is an object containing a meta and data entries for those objects that meet the conditions. However, it simply returns an array of objects. There are no meta data. Also, the condition is not tested against. Even unexpected objects are returned. Has the API changed? Am I making the wrong call or is it just a bug? If not what is now the right way to fetch all objects from a bucket that satisfy a condition and where the result contains both the data and the meta data?
Thanks in advance
José
PS: I am using coffeescript, but it shouldn't change anything

@roidrage
Copy link
Contributor

Support for a where condition in getAll hasn't been ported over to the 0.9 implementation.

I have my doubts that it will, because it's bad practice to fetch and query objects like this. You should be using secondary indexes or Riak Search instead. If you have a more complex query, combine one of the two with MapReduce.

@roidrage
Copy link
Contributor

That said, I'll look into updating the code to return meta objects too.

@joques
Copy link
Author

joques commented Nov 27, 2012

that'll be great. As for the where condition, I'll adapt my code
thanks again
On Nov 27, 2012, at 1:39 PM, Mathias Meyer [email protected] wrote:

That said, I'll look into updating the code to return meta objects too.


Reply to this email directly or view it on GitHub.

@joques
Copy link
Author

joques commented Nov 27, 2012

also, you may wanna update the documentation to reflect what is currently possible with getAll and the where option.

On Nov 27, 2012, at 1:39 PM, Mathias Meyer [email protected] wrote:

That said, I'll look into updating the code to return meta objects too.


Reply to this email directly or view it on GitHub.

@roidrage
Copy link
Contributor

Yup, already removed the reference to where.

@joques
Copy link
Author

joques commented Nov 27, 2012

Mathias,
even the mapreduce is confusing me. I can't get the key. when I do this

dbClient.mapreduce.add(fullBucketName).map((value) ->
Riak.mapValuesJson(value)
).run((error, result) -> callback error, result)

It simply returns an array of objects. From your book I understood that this was supposed to return a bucket and a key. Am I missing the point about the map reduce?
thanks in advance for your support
José

On Nov 27, 2012, at 6:07 PM, Mathias Meyer [email protected] wrote:

Yup, already removed the reference to where.


Reply to this email directly or view it on GitHub.

@roidrage
Copy link
Contributor

roidrage commented Dec 4, 2012

@joques that query only extracts the value from the Riak object, hence the call to Riak.mapValuesJson(value). Should my book state otherwise, that needs to be fixed.

@joques
Copy link
Author

joques commented Dec 8, 2012

okay! what is then the proper method to extract both values and meta data during a map/reduce. I couldn't find it in the documentation
thanks in advance

On Dec 4, 2012, at 12:40 PM, Mathias Meyer [email protected] wrote:

@joques that query only extracts the value from the Riak object, hence the call to Riak.mapValuesJson(value). Should my book state otherwise, that needs to be fixed.


Reply to this email directly or view it on GitHub.

@joques
Copy link
Author

joques commented Dec 8, 2012

please ignore my previous email.

On Dec 4, 2012, at 12:40 PM, Mathias Meyer [email protected] wrote:

@joques that query only extracts the value from the Riak object, hence the call to Riak.mapValuesJson(value). Should my book state otherwise, that needs to be fixed.


Reply to this email directly or view it on GitHub.

@ottok
Copy link

ottok commented May 22, 2013

Could you please add some [rows: 20} or similar option to getAll, so that we could at query time set an upper limit on how much getAll returns?

@roidrage
Copy link
Contributor

@ottok when it comes to just querying all data in a bucket, there is no way to do this in Riak. It will always have to fetch the entire data set. In general, using getAll is something to be avoided in production or on any decent-size data set.

@ottok
Copy link

ottok commented May 22, 2013

Exactly because getAll would most of the time return too many things, this kind of row limiter would be usefult.

Another approach would be to run db.search.find('products', '*', {rows: 20, start: 0)), but unfortunately it does not seem to work even though db.search.find('products', 'title:Ti*', {rows: 20, start: 0)) does work.

@roidrage
Copy link
Contributor

Adding a row limiter to the function itself would not cause Riak to automatically fetch a smaller set of data. It would still try to go ahead and fetch all data from the cluster.

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

3 participants