On 3/27/23 12:47, Cesar Delgado wrote:
I’m getting a strange error when trying to index some documents. Solr is
telling me the document is missing a filed when it doesn’t seem to be.
Solr error:
{'error': {'metadata': ['error-class', 'org.apache.solr.common.SolrException',
'root-error-class', 'org.apache.solr.common.SolrException'], 'msg': '[doc=null]
missing required field: account_acct', 'code': 400}} :
JSON being sent :
{'add': {'doc': {'created_at': '2023-03-26T21:44:00.000Z', 'edited_at': None,
'favourites_count': 0, 'id': 'AU1JwxeZAe5IbwzC76', 'in_reply_to_account_id':
'AJaIwDfMawY8DiOjrM', 'in_reply_to_id': 'AU1JwxWPexYwCfAgPA', 'language': None,
'pleroma': {'content': {'text/plain': '@hanmyoucache :hpexpectopatronum: 去說 is
chosen from 去說不去說'}, 'context':
'tag:o3o.ca,2023-03-26:objectId=46494613:objectType=Conversation',
'conversation_id': 1573060705, 'direct_conversation_id': None,
'emoji_reactions': [], 'expires_at': None, 'in_reply_to_account_acct':
'hanmyouca...@o3o.ca', 'local': False, 'parent_visible': True, 'pinned_at':
None, 'spoiler_text': {'text/plain': ''}, 'thread_muted': False},
'reblogs_count': 0, 'replies_count': 0, 'sensitive': False, 'spoiler_text': '',
'text': None, 'uri':
'https://onlycasino.legal/users/fatelab/statuses/110091766387251927', 'url':
'https://onlycasino.legal/@fatelab/110091766387251927', 'visibility': 'public',
'account_id': 'AG6IaEINkqwPC6G7kW', 'account_username': ['@fatelab',
'fatelab'], 'account_acct': ['@fatelab@onlycasino.legal',
'fatelab@onlycasino.legal'], 'website': 'onlycasino.legal', 'urls':
['https://o3o.ca/@hanmyoucache'], 'content': '@hanmyoucache
:hpexpectopatronum:\n\n去說\n\nis chosen from\n\n去說 \n不去說\n\n'}}}
Thanks to an annoying new default in Thunderbird, I accidentally sent
this reply direct to Cesar.
---
I ran that JSON through a pretty printer so I could actually see its
structure.
I've never seen any ability in Solr to properly deal with a nested JSON
structure like what you have for "plemora". Solr has a completely flat
document structure. There is a nested document feature, but I'm pretty
sure that it isn't done with that kind of JSON. I've never actually
used it.
If I try to index that JSON into a schema with a "*" dynamicField that's
multiValued, and only "id" required, it indexes FOUR documents, not one.
And only one of the four documents has the account_acct field.
If I completely remove the plemora structure and send the modified JSON,
then it indexes one document as expected.
You're going to need to change your JSON structure into a flat document.
Thanks,
Shawn