missing_field error using riaksearch

Morten Siebuhr sbhr+lists at sbhr.dk
Wed Mar 9 12:55:02 EST 2011


Hi,

On Wed, Mar 9, 2011 at 3:50 PM, Rusty Klophaus <rusty at basho.com> wrote:
> Hi Morten,
> The error message is indicating that your document contains an
> "organizations_name" field, but that the field doesn't exist in your schema.
> Your options are to either add a field definition for "organizations_name"
> to the schema, or add a dynamic field definition to the end of your schema
> that catches any fields that weren't previously matched, and maps them to
> some data type.
> The wiki contains more information on dynamic fields
> (http://wiki.basho.com/Riak-Search---Schema.html) but you can also just copy
> the entries from the default schema.

Thanks for the quick response!

It turned out I'd missed the difference between using:

    {field, [{name, "*"}, ...]}

and:

    {dynamic_field, [{name, "*"}, ...]}

Likewise, I had not quite gotten the fact that all fields must
explicitly be covered in the schema definition, not just the subset
you want to do searches on.

>> Hi all,
>>
>> I'm trying to use Riak + Riaksearch as a datastore for Portable
>> Contacts [1], but I'm running into a spot of trouble making riaksearch
>> actually work;
>>
>> I've set up riaksearch with the following schema document:
>>
>> {
>>        schema,
>>        [
>>                {version, "0.1"}, {default_field, "_owner"}, {n_val, 1}
>>        ],
>>        [
>>                %% Don't parse _id and _owner, just treat it as single
>> token
>>                {field, [       {name, "id"},
>>                                {required, true},
>>                                {analyzer_factory, {erlang, text_analyzers,
>> noop_analyzer_factory}}
>>                        ]},
>>                {field, [       {name, "_owner"},
>>                                {required, true},
>>                                {analyzer_factory, {erlang, text_analyzers,
>> noop_analyzer_factory}}
>>                        ]},
>>                %% Parse Name fields for full-text indexing
>>                {field, [       {name, "displayName"},
>>                                {aliases, ["nickname", "preferredUsername",
>> "name_formatted",
>> "name_displayName"]},
>>                                {analyzer_factory, {erlang, text_analyzers,
>> standard_analyzer_factory}}
>>                        ]},
>>                {field, [       {name, "emails_value"},
>>                                {analyzer_factory, {erlang, text_analyzers,
>> standard_analyzer_factory}}
>>                        ]},
>>
>>                %% Add modification dates
>>                {field, [       {name, "published"},
>>                                {aliases, ["updated"]},
>>                                {type, date}
>>                        ]}]}.
>>
>> (Edited slightly for shortness...)
>>
>> I then add it using
>> > sudo sudo search-cmd set_schema PortableContacts
>> > `pwd`/pocolib/drivers/riak-search/schema.erl
>>
>> And enable it on the 'PortableContacts' bucket:
>> > sudo search-cmd install PortableContacts
>>
>> (BTW: It is not entirely clear from
>> https://wiki.basho.com/Riak-Search---Schema.html if the schema name
>> must match the bucket it should work for. At least, I'm not entirely
>> sure.)
>>
>> But when I then try to push a contact entry, it coughs up an 500
>> Internal Server Error:
>>
>> curl -v -d '{"organizations": [{"name": "nickels principles", "title":
>> "curvier floppies"}], "displayName": "reverberating agrarian clue",
>> "name": {"givenName": "reverberating", "formatted": "reverberating
>> agrarian clue", "familyName": "agrarian clue"}, "emails": [{"value":
>> "shortcut at example.com"}], "_owner": "msi at one.com", "published":
>> "2010-04-26T13:10:33Z", "id": "48cad5d0-f057-4316-905e-281d1da32a01"}'
>> -H "Content-Type: application/json"
>>
>> http://localhost:8098/riak/PortableContacts/48cad5d0-f057-4316-905e-281d1da32a01
>> * About to connect() to localhost port 8098 (#0)
>> *   Trying ::1... Connection refused
>> *   Trying 127.0.0.1... connected
>> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> > POST /riak/PortableContacts/48cad5d0-f057-4316-905e-281d1da32a01
>> > HTTP/1.1
>> > User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7
>> > OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
>> > Host: localhost:8098
>> > Accept: */*
>> > Content-Type: application/json
>> > Content-Length: 396
>> >
>> < HTTP/1.1 500 Internal Server Error
>> < Vary: Accept-Encoding
>> < Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic)
>> < Date: Wed, 09 Mar 2011 13:51:50 GMT
>> < Content-Type: text/html
>> < Content-Length: 749
>> <
>> <html><head><title>500 Internal Server
>> Error</title></head><body><h1>Internal Server Error</h1>The server
>> encountered an error while processing this
>> request:<br><pre>{error,{error,badarg,
>>              [{erlang,iolist_to_binary,
>>                       [{error,missing_field,<<"organizations_name">>}]},
>>               {wrq,append_to_response_body,2},
>>               {riak_kv_wm_raw,accept_doc_body,2},
>>               {webmachine_resource,resource_call,3},
>>               {webmachine_resource,do,3},
>>               {webmachine_decision_core,resource_call,1},
>>               {webmachine_decision_core,decision,1},
>> * Connection #0 to host localhost left intact
>> * Closing connection #0
>>
>> {webmachine_decision_core,handle_request,2}]}}</pre><P><HR><ADDRESS>mochiweb+webmachine
>> web server</ADDRESS></body></html>
>>
>>
>> Any ideas as to where I'm doing something wrong?
>>
>> I'm using version 0.14.0-1 of both products on Ubuntu 10.4 x86.
>>
>> [1] http://portablecontacts.net/draft-spec.html
>>
>> --
>> Morten Siebuhr
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>




More information about the riak-users mailing list