2

I downloaded solr 4.6.1 and I am attempting to update the solr index using the following via command line:

curl http://localhost:8983/solr/update?commit=true -H 'Content-type:application/json' -d '
[{
  "id" : "1",
  "phoneNumber_ss": [{"foo_ss" : "bar"}]
}]
'

I am using the example schema.xml, which is why i used all the "_ss" fields.

The issue is that when I execute this I get the following response:

{"responseHeader":{"status":400,"QTime":1},"error":{"msg":"Error parsing JSON field value. Unexpected OBJECT_START","code":400}}

This seems to be related to the value specified for phoneNumber_ss field which is an array of objects. If I make the value into an array or an object it works fine, its only when it is an array of objects that the issue occurs.

Any help is much appreciated.

britt
  • 83
  • 3
  • 5

1 Answers1

4

I don't think Solr support storing objects into a multivalued field. You can store it as a array of string. You might also store the object as a string and parse it in your application.

If you have such use case that you want to have all the objects from Solr only, you can follow the steps..

  1. Create a multivalued field for your keys.
  2. Maintain the same order of keys and create another multivalued field for values.

So, you can get the keys and values in same order in different fields. But in this approach you might face problems while updating those multivalued fields. You might want to look here

And finally, you are also missing some syntax in your update statement.

set – set or replace a particular value, or remove the value if null is specified as the new value

add – adds an additional value to a list

Check http://wiki.apache.org/solr/UpdateJSON

Community
  • 1
  • 1
buddy86
  • 1,434
  • 12
  • 20
  • The "/update" is what is suggested on the wiki page you linked. I will look into breaking up my object and store it differently. Thanks – britt Feb 02 '14 at 12:19