Reputation: 580
I'm getting error when implementing in my app. Here is my error console:
filters: Unexpected token \'(\' expected \')\' at col 81' }
I'm new to Algolia. Can anyone help to shot out my error? Here is my content in algolia displaying:
objectID:asdfasfwersa1as54asdf
_id: "asdfasfwersa1as54asdf"
status: "OK"
appId: "app_4s54f"
nameId: "abc_test_(test_app)"
name: "abc test(test app)"
Here is my query:
FilterSearch= {
filterQuery: function (customQuery, type) {
var filters = "";
if (type == "Website") {
filters = "status:OK";
}
else if (!_.isEmpty(customQuery.nameId)) {
if (filters != "")filters += " AND ";
filters += "(nameId:" + customQuery.nameId.join(" OR nameId:") + ")";
}
return {filters: filters, searchKeyword: customQuery.searchKeyword};
}
};
var searchCriteria=FilterSearch.filterQuery(condition,type);
index.search(searchCriteria.searchKeyword,{facets:facetName,filters:searchCriteria.filters},,Meteor.bindEnvironment(function searchDone(err, content) {
console.log(searchCriteria.filters);
if(err) {
console.error('Algolia returned an error', err);
future.return(err);
}
else {
if(content.facets[facetName] != undefined) {
Names.find({$and: [{_id: {$in: _.keys(content.facets[facetName])}}]})
}
}
}));
Thanks
Upvotes: 1
Views: 269
Reputation: 12002
It seems like you'll need to use quotes around your nameId
values because they contain characters the filters
parser isn't able able to handle as being part of a value.
filters += "(nameId:\"" + customQuery.nameId.join("\" OR nameId:\"") + "\")";
You'll also need to escape double quotes if your nameId
field can contain some.
Upvotes: 1