Arrays 将数组声明到searchFields Worklight JSONStore中
我使用JSONStore在我的集合中有一个JSON对象,如下所示:Arrays 将数组声明到searchFields Worklight JSONStore中,arrays,search,field,ibm-mobilefirst,jsonstore,Arrays,Search,Field,Ibm Mobilefirst,Jsonstore,我使用JSONStore在我的集合中有一个JSON对象,如下所示: { name : 'name1', industry : ['Banking', 'Energy', 'Insurance', 'Media', 'Retail', 'Telco', 'Travel'], buyer : ['CMO'], link : 'foo.com' } 但是,如何将行业字段声明为searchFields?以便在数组中搜索模式 干杯搜索字段没有数组类型。您只能索引对象中的
{
name : 'name1',
industry : ['Banking', 'Energy', 'Insurance', 'Media', 'Retail', 'Telco', 'Travel'],
buyer : ['CMO'],
link : 'foo.com'
}
但是,如何将行业字段声明为searchFields?以便在数组中搜索模式
干杯搜索字段没有
数组
类型。您只能索引对象中的值,这些对象是字符串
、布尔值
、数字
和整数
你可以改变:
{ industry : ['Banking', 'Energy'] }
致:
然后使用以下搜索字段:{'industry.name':'string'}
。这将使您能够执行类似于WL.JSONStore.get('collection').find({'industry.name':'Banking'},{exact:true})
的操作,并返回如下对象:
[{_id: ..., json: {name: ..., industry: [..., {name: Banking}, ...], buyer: ..., link: ...}}]
这将记录在文档中“通用术语”的“搜索”字段部分中
这意味着要编写这样的代码来更改添加到集合中的数据:
var output = [];
['Banking', 'Energy', 'Insurance', 'Media'].forEach(function (element) {
output.push({name: element});
});
console.log( JSON.stringify(output, null, ' ') );
或者,您也可以将其更改为字符串:
{industry : ['Banking', 'Energy', 'Insurance', 'Media'].toString() }
然后得到像这样的东西:
{industry : "Banking,Energy,Insurance,Media"}
然后,您可以使用搜索字段{industry:'string'}
执行类似WL.JSONStore.get('collection')。查找({industry:'Energy'},{exact:false})
以获取industry
值字符串中某处具有能量的对象
仅供参考-功能请求。搜索字段没有数组类型。您只能索引对象中的值,这些对象是字符串
、布尔值
、数字
和整数
你可以改变:
{ industry : ['Banking', 'Energy'] }
致:
然后使用以下搜索字段:{'industry.name':'string'}
。这将使您能够执行类似于WL.JSONStore.get('collection').find({'industry.name':'Banking'},{exact:true})
的操作,并返回如下对象:
[{_id: ..., json: {name: ..., industry: [..., {name: Banking}, ...], buyer: ..., link: ...}}]
这将记录在文档中“通用术语”的“搜索”字段部分中
这意味着要编写这样的代码来更改添加到集合中的数据:
var output = [];
['Banking', 'Energy', 'Insurance', 'Media'].forEach(function (element) {
output.push({name: element});
});
console.log( JSON.stringify(output, null, ' ') );
或者,您也可以将其更改为字符串:
{industry : ['Banking', 'Energy', 'Insurance', 'Media'].toString() }
然后得到像这样的东西:
{industry : "Banking,Energy,Insurance,Media"}
然后,您可以使用搜索字段{industry:'string'}
执行类似WL.JSONStore.get('collection')。查找({industry:'Energy'},{exact:false})
以获取industry
值字符串中某处具有能量的对象
供参考-功能请求