Hi, I have been trying to replicate the structure of this example;
https://www.wix.com/corvid/example/filter-with-multiple-options
My goal is to have additional pages on my blog website and on these pages, I want to provide a way to filter the posts with multiple categories. I adapted the code in the example to my prototype page, but I keep getting “Unsupported filter operator $hasAll for Categories” error when I click on the filter tags in preview. One thing I don’t understand is the “selectedCategories” part of the code. There are no elements labelled categories in the example, so I don’t know what it exactly is referring to. My adapted code is below: (It brings blog posts to the repeater but gives an error message when I click filter tags) Any help would be much appreciated.
import wixData from ‘wix-data’;
const collectionName = ‘Blog/Posts’;
const fieldToFilterByInCollection = ‘Categories’;
$w.onReady( function () {
setRepeatedItemsInRepeater()
loadDataToRepeater()
$w(‘#selectionTags’).onChange((event) => {
const selectedSelectionTags = $w(‘#selectionTags’).value
loadDataToRepeater(selectedSelectionTags)
})
});
function loadDataToRepeater(selectedCategories = ) {
let dataQuery = wixData.query(collectionName)
if (selectedCategories.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories)
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items
$w(‘#blogPosts’).data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w(‘#noResultsFound’).show()
} else {
$w(‘#noResultsFound’).hide()
}
})
}
function setRepeatedItemsInRepeater() {
$w(‘#blogPosts’).onItemReady(($item, itemData) => {
$item(‘#coverImage’).src = itemData.coverImage;
$item(‘#coverImage’).tooltip = itemData.title;
$item(‘#title’).text = itemData.title
$item(‘#excerpt’).text = 'By ’ + itemData.excerpt;
})
}
These are the already provided examples for working with the Wix Blog app.
https://www.wix.com/corvid/examples?category=blog
You might also want to use the hashtags field as well.
https://support.wix.com/en/article/corvid-wix-blog-posts-collection-fields#hashtags-hashtags-1
Hashtags (hashtags)
Description : List of all hashtags in the post.
Type : Tags
Can connect to data : No
Can use in dynamic page URL : No
Can be sorted : No
Can be filtered : hasAll, hasSome
Read-only : Yes
https://www.wix.com/corvid/reference/$w.SelectionTags.html
Also, I would double check that the fields that you are trying to use are actually allowing that type of data query on it as not all of the fields in Wix apps are filterable etc.
https://support.wix.com/en/corvid-by-wix/wix-blog-with-corvid
Finally, note that the categories field in the Wix Blog Posts Collection is actually a reference field from the Wix Blog Categories Collection.
Categories (categories)
Description : The categories assigned to the post, referenced from the Blog/Categories collection.
Type : Multiple-item reference
Can connect to data : No
Can use in dynamic page URL : No
Can be sorted : No
Can be filtered : hasAll, hasSome, contains
Read-only : Yes
GOS thanks a lot for the answer. The examples you linked, unfortunately, do not provide the filtering I need. I want to to be able to select several options out of many, and end up with an intersection set of all the selected options. The idea is to narrow down the search by selecting additional filters. It works in the example I linked on my first post.
I thought I would be able to use the categories field under the Posts dataset. I also tried adding hashtags to posts and using the hashtags field as a filter. (Did not work.) Both seem to be filterable by hasAll according to the link you provided.
“Finally, note that the categories field in the Wix Blog Posts Collection is actually a reference field from the Wix Blog Categories Collection.” I think my problem may lie here, but I don’t understand what I need to do. I tried using the Labels from Blog Categories Collection, but that also did not work.
I have just tested it myself and it does not work with the Wix Blog app own collection as it is read only.
If you use your own dataset and export the Wix Blog Posts collection data into that new dataset, then it will work.
https://givemeawhisky.wixsite.com/tagstest
import wixData from 'wix-data';
const collectionName = 'test';
const fieldToFilterByInCollection = 'tags';
$w.onReady(function () {
setRepeatedItemsInRepeater()
loadDataToRepeater()
$w('#tags').onChange((event) => {
const selectedTags = $w('#tags').value
loadDataToRepeater(selectedTags)
})
});
function loadDataToRepeater(selectedCategories = []) {
let dataQuery = wixData.query(collectionName)
if (selectedCategories.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories)
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items
$w('#blogPosts').data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show()
} else {
$w('#noResultsFound').hide()
}
})
}
function setRepeatedItemsInRepeater() {
$w('#blogPosts').onItemReady(($item, itemData) => {
$item('#blogimage').src = itemData.coverImage;
$item('#blogname').text = itemData.title;
$item('#publisheddate').text = 'By ' + itemData.publishedDate;
})
}
The Wix Blog test one is here.
https://givemeawhisky.wixsite.com/tagstest/test
import wixData from 'wix-data';
const collectionName = 'Blog/Posts';
const fieldToFilterByInCollection = 'Hashtags';
$w.onReady(function () {
setRepeatedItemsInRepeater()
loadDataToRepeater()
$w('#tags').onChange((event) => {
const selectedTags = $w('#tags').value
loadDataToRepeater(selectedTags)
})
});
function loadDataToRepeater(selectedCategories = []) {
let dataQuery = wixData.query(collectionName)
if (selectedCategories.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories)
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items
$w('#blogPosts').data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show()
} else {
$w('#noResultsFound').hide()
}
})
}
function setRepeatedItemsInRepeater() {
$w('#blogPosts').onItemReady(($item, itemData) => {
$item('#blogimage').src = itemData.coverImage;
$item('#blogname').text = itemData.title;
$item('#publisheddate').text = 'By ' + itemData.publishedDate;
})
}
GOS thank you again for your answer. Since exporting/importing the collection each time I posted something new would be very unpractical, I decided to skip the blog app and simply build the pages using my custom database collection. And the filtering function works just fine this way. Without your help I would spend many more hours without understanding why the blog database collections didn’t work in my case!
This was bugging me all day, so I thought I would take another look at it with a fresh pair if eyes 
And guess what, I only got it working with the Wix Blog Posts collection!
Yet will I tell you how to do it… 

Of course I will and it only took one very, very, very and I mean very simple change!
All that was needed was for this line here to have the field key and not the field name, hindsight now it is very obvious!
const fieldToFilterByInCollection = 'Hashtags';
should be
const fieldToFilterByInCollection = 'hashtags';
So, if you check out the Wix Blog collection test page now with the selection tags, it all works fine using the hashtags already setup in the collection when you add it to your site.
https://givemeawhisky.wixsite.com/tagstest/test
So, just to recap, the code in previous reply titled ‘The Wix Blog test one is here.’, will work fine if you just change the field to hashtags (field key not name).
Last thing to mention is to remember that the hasAll function is case sensitive as stated in the Wix API Reference for it.
Matching strings with hasAll() is case sensitive, so “text” is not equal to “Text”.
In the Wix Blog Posts collection they are all lowercase, so you can have the label as upper and lower case, yet the value must all be in lower case to match the tag.
Hey GOS, Forgive me for asking on another post but i’m having a similar problem,
Sorry to put this here but I made a post but with no response, in my case I just want to filter the collection by the blog category that gets loaded into the repeater before the user input filter comes in.
https://www.wix.com/corvid/forum/community-discussion/trying-to-filter-collection-by-blog-category?origin=member_posts_page
I tried a few solutions like in the link but no luck,
Any help will be appreciated