Hi Daniel,
Searching within Riak (and hence associations) has always been wacky.
The riakc library API changes with annoying frequency.
Anyway try this patch and let me know if it works better:
https://github.com/evanmiller/boss_db/commit/5fd838542868de28ffb6f2782480dfff8ecb3cbd
On Sun, Mar 31, 2013 at 4:06 PM, <
daniel....@gmail.com> wrote:
> Hi -,
>
> I'm toying around with CB 0.8.5 and Riak 1.3, and I think I have encountered
> a bug (but it seems so fundamental that I'm mostly confused about what's
> happening).
>
> I currently have three models:
>
> account
> comment
> post
>
> With the following associations set up between the three:
>
> account
> -has({posts, many}).
> comment
> -belongs_to(account).
> -belongs_to(post).
> post
> -belongs_to(account).
> -has({comments, many}).
>
> Everything is working fine when using the mock adapter, but once I switch to
> riak, I'm seeing errors like this one:
>
> {{function_clause,
> [{lists,map,
> [#Fun,{search_results,[],0.0,0}],
> [{file,"lists.erl"},{line,1172}]},
> {boss_db_adapter_riak,find,7,
> [{file,"src/db_adapters/boss_db_adapter_riak.erl"},{line,63}]},
> {boss_db_controller,handle_call,3,
> [{file,"src/boss_db_controller.erl"},{line,114}]},
> {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,588}]},
> {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]},
> {gen_server,call,
> [<0.95.0>,
> {find,post,
> [{account_id,equals,"account-VypnEwwcghmSLe9mQczhezcTZoN"}],
> all,0,id,ascending,[]},
> 30000]}}
>
>
> This is happening when fetching an account (and trying to access the posts
> association in a template), so it looks like BossDB is trying to fetch all
> posts related to an account (using the account_id field on posts) and then
> fails. At first I thought that it's because the user simply has no posts,
> but it also happens after I added one (and made sure the account_id field
> points to the right user).
>
>
> Here is what I did to "set up" Riak (only what the README said):
>
> Enabled riak_search via app.config
> "Installed" the following search commands:
> - account
> - comments
> - posts
>
> When I check the buckets they all say search: true and have the following
> precommit hook:
>
> {
>
> "mod": "riak_search_kv_hook",
>
> "fun": "precommit"
>
> }
>
>
> So I'm pretty sure I've set up Riak correctly.
>
> After searching around for a bit, I found this:
>
https://groups.google.com/d/msg/chicagoboss/9XBTg2HHmrI/TJGtVFiYZIIJ It
> sounds like this could be related, but Im really not sure.
>
> Btw. Running boss_db:find("account-VypnEwwcghmSLe9mQczhezcTZoN") (in the
> REPL) works just fine, because it looks like it's not fetching the
> association. What doesn't work however, is something like this:
> boss_db:find(post, [{account_id, "account-VypnEwwcghmSLe9mQczhezcTZoN"}])
> (getting the same error as above).
>
> I do realize that the Riak adapter is marked as experimental, but
> associations should work, right?
>
> Best regards.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
chicagoboss...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Evan Miller
http://www.evanmiller.org/