Hi, i’m trying to implement this filtering functionality using the Entity Service API and it only works with fields that are not nested such as id, code:
plugin.controllers["collection-types"].find = async (ctx) => {
const params = processFilters(
Object.fromEntries([...new URLSearchParams(ctx.request.querystring)])
);
const [sortKey, sortOrder] = params.sort.split(":");
const uid = ctx.request.url.split("?").shift().split("/").pop();
const req = {
...params,
page: params.page || 1,
pageSize: params.pageSize || 10,
populate: "deep,2",
};
if (sortKey) {
req.sort = {
[sortKey]: sortOrder,
};
}
if (params._q) {
const { attributes } = strapi.contentTypes[uid];
const filters = {
$or: [
{
publishing: {
permalink: {
$containsi: params._q,
},
},
},
{
banner: {
title: {
$containsi: params._q,
},
},
},
{
id: {
$containsi: params._q,
},
},
],
};
Object.keys(attributes).forEach((key) => {
if (["string", "text", "richtext"].includes(attributes[key].type)) {
filters.$or.push({ [key]: { $containsi: params._q } });
}
});
req.filters = { ...req.filters, ...filters };
}
return await strapi.entityService.findPage(uid, req);
};
In that case it doesn’t find the permalink nor the banner title