Hi Ryan,

Thanks for the information! I'm developing an erlang application and wanted to 
write erlang data and run the Riak Search on them by using the riakc. Before 
doing so, I tried to check how it works by using the HTTP interface, and then 
got the issue that I asked the question about. 

I don't have to stick with the erlang data. So as you advised I will use JSON 
to avoid any potential issues.

Best regards,
 Takeshi

On 2013/01/23, at 14:20, Ryan Zezeski <[email protected]> wrote:

> Takeshi,
> 
> The erlang extractors don't work when writing the data via HTTP as they store 
> the data as a binary.  I.e. [{"name", "bob"}] becomes <<"[{\"name\", 
> \"bob\"}]">> instead of the proplist you expect.  This is because the 
> extractor assumes the object data is already properly decoded.  It is 
> possible to write erlang terms via the erlang client, but I wouldn't 
> recommend it as it is not the common case and I feel like there are other 
> issues lurking in Riak if you do this.  If there a particular reason you are 
> trying to store erlang terms?  Are you worried about space?  I would just 
> stick with JSON or XML if that is acceptable.
> 
> -Z
> 
> 
> On Tue, Jan 22, 2013 at 10:15 AM, Takeshi Matsumura <[email protected]> 
> wrote:
> Hi,
> 
> I tried to store erlang data and query them by using the Riak Search without 
> success so far, and thus would like to ask if I'm doing the right thing. Riak 
> Search was enabled in the app.config file and the server was restarted. The 
> pre-commit hook was installed from the command line.
> 
> bin/search-cmd install mybucket
> 
> The erlang data that I uploaded is a proplists with a single pair of key and 
> value.
> 
> [{"name", "bob"}]
> 
> It was uploaded by using the curl command with Content-Type 
> "application/x-erlang". (hoge.erl.txt contains the above erlang terms).
> 
> curl -v -d @hoge.erl.txt -X PUT -H "content-type: application/x-erlang" 
> "http://localhost:8098/riak/mybucket/bob";
> 
> I could get the document by issuing curl command to "/riak/mybucket/bob". The 
> HTTP response header contained the correct Content-Type, 
> "application/x-erlang".
> 
> Then I run the Riak Search from the command line.
> 
> bin/search-cmd search mybucket "name:bob"
> 
> Unfortunately, the result said "Found 0 results".
> 
> As I wondered if this is a problem related to the erlang terms, I tried the 
> same with a JSON data that is found in the "Indexing and Querying KV Data" 
> page but setting "application/json" to the Content-type.
> 
> {
>  "name":"Alyssa P. Hacker",
>  "bio":"I'm an engineer, making awesome things.",
>  "favorites":{
>               "book":"The Moon is a Harsh Mistress",
>               "album":"Magical Mystery Tour"
>              }
> }
> 
> Then the Riak Search could find this document with the query "name:Alyssa*".
> 
> According to the "Indexing and Querying KV Data" page of the Riak document, 
> erlang terms can be queried by using the Riak Search. However, it is unclear 
> to me if it is enabled by default because the page says XML, JSON, and 
> plain-text encodings are supported out of the box but it doesn't mention the 
> erlang terms.
> 
> I followed the "Other Data Encodings" section and set the 
> "riak_search_kv_erlang_extractor" module, but it didm't change the situation.
> 
> curl -XPUT -H 'content-type: application/json' \
>     http://localhost:8098/riak/mybucket \
>     -d 
> '{"props":{"search_extractor":{"mod":"riak_search_kv_erlang_extractor", 
> "fun":"extract", "arg":"my_arg"}}}'
> 
> I changed the data as follows and uploaded but it didn't help either.
> 
> [{<<"name">>, <<"bob">>}]
> 
> I appreciate any hints for me to go forward. Thank you in advance.
> 
> Best regards,
>  Takeshi
> 
> 
> 
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to