Search with metadata: teamplateA.field=X or templateB.field=X
AnsweredI'm looking for a way to do a search based on different templates, something like: templateA.field = AAA or templateB.field = AAA
Could someone give me a hint of is it possible at all?
My code below:
{code}
const BoxSDK = require('box-node-sdk');
const sdkConfig = require('./config.json');
(async () => {
var sdk = BoxSDK.getPreconfiguredInstance(sdkConfig);
var client = sdk.getAppAuthClient('enterprise');
client.asUser('XXXXX');
const filterA = {
templateKey: 'templateA',
scope: 'enterprise_XXXX',
filters: { psPartNo: '11111' }
};
const filterB = {
templateKey: 'templateB',
scope: 'enterprise_XXXX',
filters: { psPartNo: '11111' }
};
await client.search.query('', {
ancestor_folder_ids: '0',
fields: 'name',
mdfilters: [ filterA ]
})
.then(r => console.log('Result has', r.total_count, 'items:', r.entries.map(x => x.name).join(', ')))
.catch(e => console.log(e.message));
// Result has 1 items: ....
await client.search.query('', {
ancestor_folder_ids: '0',
fields: 'name',
mdfilters: [ filterB ]
})
.then(r => console.log('Result has', r.total_count, 'items:', r.entries.map(x => x.name).join(', ')))
.catch(e => console.log(e.message));
// Result has 2 items: ....
// *************
// Here i'm looking of how to:
// 1) use multiple templates
// 2) use OR condition
await client.search.query('', {
ancestor_folder_ids: '0',
fields: 'name',
mdfilters: [ filterA, filterB ]
})
.then(r => console.log('Result has', r.total_count, 'items:', r.entries.map(x => x.name).join(', ')))
.catch(e => console.log(e.message));
})();
// Unexpected API Response [400 Bad Request | **** ] bad_request - Bad Request
{code}
-
Official comment
Hi Anton
Currently you can only search against a single metadata template in Box search and metadata query API.
You can upvote and add your comments/use case to this pulse request which asks for the functionality you need.
Best regards
Peter Christensen, Platform Solutions Engineer, Box
Comment actions
Please sign in to leave a comment.
Comments
1 comment