riak search indexing arrays of integers

Joseph Lambert joseph.g.lambert at gmail.com
Mon Feb 14 01:20:31 EST 2011


Hi,

If I want to put a json object which has an array of integers, like:

{
   "users" : [ 1971, 7844 ]
}

and index that as integers with the schema:

{field, [
    {name, "users"},
    {type, integer},
    {analyzer_factory, {erlang, text_analyzers, integer_analyzer_factory}}
]},

The indexing works (I am assuming correctly) and I have these values in the
index document:

{<<"users">>,<<"1971 7844">>,  [{<<"1971">>,[0]},{<<"7844">>,[1]}]}

However, in my schema I have the type as integer for this index, and when I
get the object I get an error for riak_search_utils:to_integer is failing,
because this is not valid:

list_to_integer("1971 7844")

I patched the to_integer function so that if it is a single integer, it just
returns list_to_integer("1971"), but if there is more than one integer, it
will return a list of integers, like so:

1) single integer values: 1971
2) list of integer values:  [1971, 7844]

My question now is, is that acceptable behavior to return a list of integers
in this case? It seems to work fine with search and all, but I haven't
tested it extensively. Also, it's kind of hacky and only applies to the
to_integer function.

- Joe Lambert

joseph.g.lambert at gmail.com
+86 13656213284
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110214/3c1a0b64/attachment.html>


More information about the riak-users mailing list