I have an two tables:-
Countries Customers [have a number of column- ike name, address, city, zipcode, email, etc] Customer table have an column country [Pointer of Countries].
Now what I want: I have a search form and if some put "aus" in a search box and click on "Search" button I want to display all matching records, I want to apply search on "Name, email, address, city, and the Country name [pointer]"
So if someone has name Austin or Country name "Australia" will be the output of search, currently, I'm using "contains" on the name, email and it is working fine.
I tried to apply search on country but not successes, could someone please help to apply this.
Here is my current code that is working [Without Country search], I am using cloud functions.
`var customerName = new Parse.Query("customer");
var customerEmail = new Parse.Query("customer");
var customerAddress = new Parse.Query("customer");
customerName.contains('name','aus');
customerEmail.contains('email','aus');
customerAddress.contains('address','aus');
var serviceQuery = new Parse.Query.or(
customerName,
customerEmail,
customerAddress
// country
);
.............` Thanks
Try something like this:
var customerName = new Parse.Query('customer');
var customerEmail = new Parse.Query('customer');
var customerAddress = new Parse.Query('customer');
customerName.contains('name','aus');
customerEmail.contains('email','aus');
customerAddress.contains('address','aus');
var countryQuery = new Parse.Query('country');
countryQuery.contains('name','aus');
var customerCountry = new Parse.Query('customer');
customerCountry.matchesQuery('country', countryQuery);
var serviceQuery = new Parse.Query.or(
customerName,
customerEmail,
customerAddress,
customerCountry
);
Instead of searching for each of customers' fields, you can use full text search: https://docs.parseplatform.org/js/guide/#full-text-search