Search code examples
filtercontainscloudboost

CloudSearch or CloudQuery to search by 'contains' in CloudBoost


I need to filter data by substring, I mean, if I have got this data:

'John','Markus','james'

And i want to look by all elements which contains 'm' it should return:

'Markus','james'

Or if I filter by 'hn', the results should be:

'John'

How can I do it using CloudSearch or CloudQuery?

EDIT: I have seen wildcard method which seems to fit with my requirements, except for only is allowed a column (string) param. I would need to filter also by columns (array). As in searchOn method.


Solution

  • This should work I think. did you try it with this :

    var query = new CB.CloudQuery('TableName');
    //then you can:
    query.substring('ColName','Text');
    //or
    query.substring(['ColName1','ColName2'],'Text');
    //or
    query.substring('ColName',['Text1', 'Text2']);
    //or
    query.substring(['ColName1','ColName2'],['Text1', 'Text2']);
    
    query.find(callback);