or( )


Refines a search to match documents that meet the condition of any of the specified filters.

The or() function joins WixSearchFilters with an inclusive or condition and adds them to a WixSearchBuilder. A search with an or() returns all the documents that match the condition of any of the filters.

If the or() function contains a single filter, the filter is applied directly to the WixSearchBuilder.

If other filtering functions were previously used in the same WixSearchBuilder instance, or() is applied using an and condition with previously set filters.

Method Declaration
Copy
function or(filters: Array<WixSearchFilter>): WixSearchBuilder;
Method Parameters
filtersArray<WixSearchFilter>Required

One or more filters.

Returns
Return Type:WixSearchBuilder
Create a search, add an or, and run it

This example demonstrates how to search for popular forum posts with either 20 or more likes or 100 or more views.

JavaScript
import wixSearch from "wix-search"; // ... const geLikeFilter = wixSearch.filter().ge("likeCount", 20); const geViewFilter = wixSearch.filter().ge("viewCount", 100); wixSearch .search() .documentType("Forum/Content") .or(geLikeFilter, geViewFilter) .find() .then((results) => { if (results.documents.length > 0) { let documents = results.documents; } else { console.log("No matching results"); } }) .catch((error) => { console.log(error); });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?