basho / riak-nodejs-client

The Riak client for Node.js.
Apache License 2.0
72 stars 28 forks source link

multiValued="true" field returns string instead of array. [JIRA: CLIENTS-870] #159

Open zhaohanweng opened 8 years ago

zhaohanweng commented 8 years ago

If the multiVauled field has 2 or more string items, then it will return array of string, which is correct. But if only have one item, it will return string instead of array of a single string.

lukebakken commented 8 years ago

Hello, could you please provide steps and code to reproduce this? Thanks.

zhaohanweng commented 8 years ago

schema: default schema + the following line in the fields.

<field name="hobbies" type="text_general" indexed="true" stored="true" multiValued="true"/>

data:

{ userId: 1, hobbies: ['soccer'] },
{ userId: 2, hobbies: ['soccer', 'tennis'] }

create solr-index-user for this schema, then create bucket props with this solr-index-user. insert the data into this bucket.

code:

riak.search({
    indexName: 'solr-index-user',
    q: "*:*"
})

results:

 [ {
      "hobbies": "soccer",
      "userId": "1"
    },
......

searching through http api will give array result even if it's one item.

http://localhost:8098/search/query/solr-index-user?wt=json&q=*:*

results:

"docs": [
      {
        "userId": "1",
        "hobbies": [
          "soccer"
        ],
        "_yz_id": "1*data*user*1*12",
        "_yz_rk": "1",
        "_yz_rt": "data",
        "_yz_rb": "user"
      }
.....