[AC-5842] Query custom objects field with $text and $search
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2018-11-28T22:10:04.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Arrow Cloud, ArrowDB, Documentation, Studio |
Labels | n/a |
Reporter | Andy Kirra |
Assignee | Shak Hossain |
Created | 2018-08-17T16:34:32.000+0000 |
Updated | 2018-11-28T22:10:04.000+0000 |
Description
I have arrowdb custom objects that have a field named “message”
I'm trying to perform a query by keywords on this field
-> my query where obj:
where = { "message" : { "$text" : { "$search" : "keyword" } } }
Following the documentation:
Perform a text search on the contents of the field. A $text expression has the following syntax:
{ "$text": { "$search": <string> }}
Also here's an example from the documentation:
where={"$text": { "$search": "javascript,ruby,python,-php" }}
+PROBLEM+
I'm getting a 500 error:
{
"success": false,
"error": true,
"code": 500,
"message": {}
}
+EXPECTED+
Perform a text search on the contents of the field message.
+TEST CASE+
The following code has 2 functions:
1(doCreate) - creates a custom "report" object (with property message = 'abc aaa bbb ccc')
2(doSearch) - query the reports by field message (by keyword 'abc')
//QUERY THE FIELD MESSAGE OF THE PREVIOUSLY CREATED CUSTOM OBJ
function doSearch(e) {
Cloud.Objects.query({
classname: 'report',
page: 1,
per_page: 10,
where: {
//WORKING QUERIES (give the expected result)
//"message" : "abc aaa bbb ccc"
//"message" : { "$regex": "^" + "abc"}
//NOT WORKING (Gives 500 error)
"message" : { "$text" : {"$search" : "abc"} }
}
}, function (e) {
if (e.success) {
for (var i = 0; i < e.report.length; i++) {
var report = e.report[i];
Ti.API.info("report: "+JSON.stringify(report,null,2));
}
} else {
Ti.API.info('Error:\n' + JSON.stringify(e,null,2));
}
});
}
//CREATE A CUSTOM OBJECT (to have an object to query )
function doCreate(e) {
Cloud.Objects.create({
classname: 'report',
fields: {
message: 'abc aaa bbb ccc',
}
}, function (e) {
if (e.success) {
var report = e.report[0];
Ti.API.info("report: "+JSON.stringify(report,null,2));
} else {
alert('Error:\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
}
Hello, Thanks for sharing with us. Can you please test this on latest SDK and let us know how it goes.
Hi, Thanks for your answer, I get the same error on SDK 7.3.0. (code: 500)
Hello, Thanks for your feedback. In which platform you are getting this error? Please attach complete test case and full console logs.