Hello,
I’ve built a query on a wix-data collection that has an array field containing keywords. I want to filter my query using WixDataQuery functions to include any item in the database which contains ANY of the inputted search words in the keyword array field.
The following code doesn’t seem to work… if the searchString (inputted search words) doesn’t exactly match one of the keyword strings in the array, the query returns 0 results.
How can I modify the searchString to include ANY of the keywords in the array without matching the string exactly?
wixData.query("Properties")
.contains("keyword", searchString)
.eq("jurisdiction", jurisdictionSelection)
.eq("database", databaseSelection)
.find()
.then((results) => {
if (results.items.length > 0) {
console.log(results);
} else {
}
}).catch((err) => {
let errorMsg = err;
});
Another way of saying this: say a database item has this array in the keywords field:
keywords = ["house", "sunshine", "garage", "three beds", "two bath"]
When a user searches the phrase “two bath house with sunshine”, I want the item to appear in the search results.
Thanks for your help! I feel like the solution is super obvious I just haven’t stumbled across it yet.
Ezra