Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown command error while posting files to solr

Tags:

solr

I am trying to post the following json format of the file to solr

{"userName": "Bill", "stars": 4, "review_id": "-TsVN230RCkLYKBeLsuz7A", "type": "review", "business_name": "Eric Goldberg, MD", "user_id": "zvJCcrpm2yOZrxKffwGQLA", "text": "Dr. Goldberg has been my doctor for years and I like him. I've found his office to be fairly efficient. Today I actually got to see the doctor a few minutes early! \n\nHe seems very engaged with his patients and his demeanor is friendly, yet authoritative. \n\nI'm glad to have Dr. Goldberg as my doctor."}

However I get the error

Response: {"responseHeader":{"status":400,"QTime":32}," error":{"msg":"Unknown command 'user_name' at [12]","code":400}}

while I am trying to do

post.sh -c coreName fileName.json

This is driving me crazy. I have unloaded the core and created it again to see if previous attempts to post files is causing this error. But that did not help.

like image 753
nnm Avatar asked Dec 24 '22 11:12

nnm


1 Answers

Solr is looking for a command (like 'add') when you send an object, so you need to either add the command, as such:

{"add": {"doc":{"userName": "Bill", "stars": 4, "review_id": "-TsVN230RCkLYKBeLsuz7A", "type": "review", "business_name": "Eric Goldberg, MD", "user_id": "zvJCcrpm2yOZrxKffwGQLA", "text": "Dr. Goldberg has been my doctor for years and I like him.  I've found his office to be fairly efficient.  Today I actually got to see the doctor a few minutes early!  \n\nHe seems very engaged with his patients and his demeanor is friendly, yet authoritative.    \n\nI'm glad to have Dr. Goldberg as my doctor."}}}

Or place it in an array:

[{"userName": "Bill", "stars": 4, "review_id": "-TsVN230RCkLYKBeLsuz7A", "type": "review", "business_name": "Eric Goldberg, MD", "user_id": "zvJCcrpm2yOZrxKffwGQLA", "text": "Dr. Goldberg has been my doctor for years and I like him.  I've found his office to be fairly efficient.  Today I actually got to see the doctor a few minutes early!  \n\nHe seems very engaged with his patients and his demeanor is friendly, yet authoritative.    \n\nI'm glad to have Dr. Goldberg as my doctor."}]

See also: https://wiki.apache.org/solr/UpdateJSON

like image 91
James Doepp - pihentagyu Avatar answered Jan 14 '23 21:01

James Doepp - pihentagyu