{ "id": "172083", "key": "AC-5842", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2018-11-28T22:10:04.000+0000", "created": "2018-08-17T16:34:32.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2018-11-28T22:10:04.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14558", "name": "Arrow Cloud" }, { "id": "14559", "name": "ArrowDB" }, { "id": "14545", "name": "Documentation" }, { "id": "14551", "name": "Studio", "description": "Please enter tickets related to Titanium Studio here." } ], "description": "I have arrowdb custom objects that have a field named “message”\r\nI'm trying to perform a query by keywords on this field\r\n\r\n-> my query where obj:\r\n\r\n{code:java}\r\nwhere = { \"message\" : { \"$text\" : { \"$search\" : \"keyword\" } } }\r\n{code}\r\n\r\n\r\nFollowing the documentation:\r\n\r\nPerform a text search on the contents of the field. A $text expression has the following syntax: \r\n\r\n{code:java}\r\n{ \"$text\": { \"$search\": }} \r\n{code}\r\n\r\n\r\nAlso here's an example from the documentation: \r\n\r\n{code:java}\r\nwhere={\"$text\": { \"$search\": \"javascript,ruby,python,-php\" }}\r\n{code}\r\n\r\n\r\n+PROBLEM+\r\n I'm getting a 500 error:\r\n {\r\n \"success\": false,\r\n \"error\": true,\r\n \"code\": 500,\r\n \"message\": {}\r\n }\r\n\r\n+EXPECTED+\r\nPerform a text search on the contents of the field message.\r\n\r\n+TEST CASE+\r\nThe following code has 2 functions:\r\n1(doCreate) - creates a custom \"report\" object (with property message = 'abc aaa bbb ccc')\r\n2(doSearch) - query the reports by field message (by keyword 'abc')\r\n\r\n\r\n\r\n{code:java}\r\n//QUERY THE FIELD MESSAGE OF THE PREVIOUSLY CREATED CUSTOM OBJ\r\nfunction doSearch(e) {\r\n\t\r\nCloud.Objects.query({\r\n classname: 'report',\r\n page: 1,\r\n per_page: 10,\r\n where: {\r\n //WORKING QUERIES (give the expected result)\r\n \t //\"message\" : \"abc aaa bbb ccc\"\r\n \t //\"message\" : { \"$regex\": \"^\" + \"abc\"} \r\n //NOT WORKING (Gives 500 error)\r\n \"message\" : { \"$text\" : {\"$search\" : \"abc\"} }\r\n }\r\n\t}, function (e) {\r\n\t if (e.success) {\r\n\t for (var i = 0; i < e.report.length; i++) {\r\n\t var report = e.report[i];\r\n\t Ti.API.info(\"report: \"+JSON.stringify(report,null,2));\r\n\t }\r\n\t } else {\r\n\t Ti.API.info('Error:\\n' + JSON.stringify(e,null,2)); \r\n\t }\r\n\t});\r\n}\r\n\r\n//CREATE A CUSTOM OBJECT (to have an object to query )\r\nfunction doCreate(e) {\r\n\t\r\nCloud.Objects.create({\r\n classname: 'report',\r\n fields: {\r\n message: 'abc aaa bbb ccc',\r\n }\r\n\t}, function (e) {\r\n\t if (e.success) {\r\n\t \t\r\n\t var report = e.report[0];\r\n\t Ti.API.info(\"report: \"+JSON.stringify(report,null,2));\r\n\t } else {\r\n\t alert('Error:\\n' +\r\n\t ((e.error && e.message) || JSON.stringify(e)));\r\n\t }\r\n\t});\r\n\t\r\n}\r\n{code}\r\n\r\n\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n", "attachment": [], "flagged": false, "summary": "Query custom objects field with $text and $search", "creator": { "name": "akirra", "key": "akirra", "displayName": "Andy Kirra", "active": true, "timeZone": "America/Toronto" }, "subtasks": [], "reporter": { "name": "akirra", "key": "akirra", "displayName": "Andy Kirra", "active": true, "timeZone": "America/Toronto" }, "environment": "Node.js\r\n Node.js Version = 8.9.1\r\n npm Version = 5.5.1\r\nTitanium CLI\r\n CLI Version = 5.1.1\r\nTitanium SDK\r\n SDK Version = 7.1.1.GA", "comment": { "comments": [ { "id": "440908", "author": { "name": "rmitro", "key": "rmitro", "displayName": "Rakhi Mitro", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hello,\r\n\r\nThanks for sharing with us. Can you please test this on latest SDK and let us know how it goes.", "updateAuthor": { "name": "rmitro", "key": "rmitro", "displayName": "Rakhi Mitro", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-08-21T04:57:14.000+0000", "updated": "2018-08-21T04:57:14.000+0000" }, { "id": "441044", "author": { "name": "akirra", "key": "akirra", "displayName": "Andy Kirra", "active": true, "timeZone": "America/Toronto" }, "body": "Hi,\r\nThanks for your answer, I get the same error on SDK 7.3.0. (code: 500)", "updateAuthor": { "name": "akirra", "key": "akirra", "displayName": "Andy Kirra", "active": true, "timeZone": "America/Toronto" }, "created": "2018-08-24T13:08:07.000+0000", "updated": "2018-08-24T13:08:07.000+0000" }, { "id": "441063", "author": { "name": "rmitro", "key": "rmitro", "displayName": "Rakhi Mitro", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hello,\r\nThanks for your feedback. In which platform you are getting this error? Please attach complete test case and full console logs.\r\n\r\n\r\n", "updateAuthor": { "name": "rmitro", "key": "rmitro", "displayName": "Rakhi Mitro", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-08-26T10:15:12.000+0000", "updated": "2018-08-26T10:15:12.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }