将默认值添加到震动中的数组
我需要将请求转换为Solr微服务。在许多其他属性中,我还有一个从Solr返回的字段列表。我确实需要在那里添加几个默认字段。 IE具有以下输入:
{
"jsonToTransform": {
"authorizedCountries": [],
"searchOptions": {
"maxRecords": "10",
"matchScore": "true",
"matchIndicators": "true",
},
"searchAttrList": {
"distanceUnit": "M",
"phoneNumber": "369283729375",
"distance": "8.5",
"latitude": 44.71663,
"longitude": 10.23196
},
"responseAttrList": ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url"]
}
}
我需要获取此输出:
{
"searchOptions" : {
"maxRecords" : "10",
"matchScore" : "true",
"matchIndicators" : "true"
},
"searchAttrList" : {
"distance" : "13.68",
"point" : "44.71663,10.23196"
},
"solrOptions" : {
"responseElementsList" : ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url","compatibilityIndex","privacyIndicator"],
"countryCodeList" : [ ],
"pnm_boost" : "1.0",
"anm_boost" : "1.0",
...
}
}
我几乎所有工作都有效,除了在 ResponselementsList 的末尾添加这两个字段。我有这个规格:
{
"operation": "default",
"spec": {
"*": {
"solrOptions": {
"anm_boost": "1.0",
"pnm_boost": "1.0",
"responseElementsList": ["compatibilityIndex","privacyIndicator"]
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"solr*": {
"*": "&1.&",
"@(1,responseAttrList)": "&1.responseElementsList",
"@(1,authorizedCountries)": "&1.countryCodeList",
...
},
"search*": "&",
"searchOptions": {
"*": "&1.&",
...
}
}
}
}
但是,作为回应,我得到了:
"responseElementsList" : ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url",["compatibilityIndex","privacyIndicator"]],
我确实尝试了其他一些变体,但它们也没有产生所需的输出。 请告诉我我做错了什么。
I need to transform request to a SOLR microservice. Among many other attributes I have a list of fields to be returned from SOLR. I do need to add a couple of default fields there.
I.e. with the following input:
{
"jsonToTransform": {
"authorizedCountries": [],
"searchOptions": {
"maxRecords": "10",
"matchScore": "true",
"matchIndicators": "true",
},
"searchAttrList": {
"distanceUnit": "M",
"phoneNumber": "369283729375",
"distance": "8.5",
"latitude": 44.71663,
"longitude": 10.23196
},
"responseAttrList": ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url"]
}
}
I need to get this output:
{
"searchOptions" : {
"maxRecords" : "10",
"matchScore" : "true",
"matchIndicators" : "true"
},
"searchAttrList" : {
"distance" : "13.68",
"point" : "44.71663,10.23196"
},
"solrOptions" : {
"responseElementsList" : ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url","compatibilityIndex","privacyIndicator"],
"countryCodeList" : [ ],
"pnm_boost" : "1.0",
"anm_boost" : "1.0",
...
}
}
I have almost everything working, except adding these two fields at the end of responseElementsList. I have this spec:
{
"operation": "default",
"spec": {
"*": {
"solrOptions": {
"anm_boost": "1.0",
"pnm_boost": "1.0",
"responseElementsList": ["compatibilityIndex","privacyIndicator"]
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"solr*": {
"*": "&1.&",
"@(1,responseAttrList)": "&1.responseElementsList",
"@(1,authorizedCountries)": "&1.countryCodeList",
...
},
"search*": "&",
"searchOptions": {
"*": "&1.&",
...
}
}
}
}
But in response I am getting :
"responseElementsList" : ["distance","locationAddressLongitude","locationAddressLatitude","name","streetAddress","city","state","postalCode","countryCode","primaryCategoryCode","categoryCodeDesc","url",["compatibilityIndex","privacyIndicator"]],
I did try some other variants but they did not produce desired output either.
Please do tell me what I am doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加
ResponselementsList
对 shift 转换,在其中步行为数组的索引,而不是整个数组>& 3 表示关键名称
“ solroptions”
以在共同对象下组合,并且& 2 代表“ ResponselementsList”
键名。You can add
responseElementsList
object to the shift transformation in which walk for the indices of the array, but not the whole array such aswhere &3 represents the key name
"solrOptions"
in order to combine under the common object, and &2 represents"responseElementsList"
key name.