After some digging into the strapi code I discovered the issue was with the use of the mysql2 library to connect to the database.
Within the strapi-connector-bookshelf package, queries.js there is method:
const buildSearchQuery = ({ model, params }) => qb => {
const query = params._q;
const associations = model.associations.map(x => x.alias);
const stringTypes = ['string', 'text', 'uid', 'email', 'enumeration', 'richtext'];
const numberTypes = ['biginteger', 'integer', 'decimal', 'float'];
const searchColumns = Object.keys(model._attributes)
.filter(attribute => !associations.includes(attribute))
.filter(attribute => stringTypes.includes(model._attributes[attribute].type))
.filter(attribute => model._attributes[attribute].searchable !== false);
if (!_.isNaN(_.toNumber(query))) {
const numberColumns = Object.keys(model._attributes)
.filter(attribute => !associations.includes(attribute))
.filter(attribute => numberTypes.includes(model._attributes[attribute].type))
.filter(attribute => model._attributes[attribute].searchable !== false);
searchColumns.push(...numberColumns);
}
if ([...numberTypes, ...stringTypes].includes(model.primaryKeyType)) {
searchColumns.push(model.primaryKey);
}
// Search in columns with text using index.
switch (model.client) {
case 'pg':
searchColumns.forEach(attr =>
qb.orWhereRaw(
`"${model.collectionName}"."${attr}"::text ILIKE ?`,
`%${escapeQuery(query, '*%\\')}%`
)
);
break;
case 'sqlite3':
searchColumns.forEach(attr =>
qb.orWhereRaw(
`"${model.collectionName}"."${attr}" LIKE ? ESCAPE '\\'`,
`%${escapeQuery(query, '*%\\')}%`
)
);
break;
case 'mysql':
searchColumns.forEach(attr =>
qb.orWhereRaw(
`\`${model.collectionName}\`.\`${attr}\` LIKE ?`,
`%${escapeQuery(query, '*%\\')}%`
)
);
break;
}
};
As the project was setup with mysql2 as the client within database.js it was skipping any of the where queries.
I see from the official docs that mysql is the supported connector so I’ve changed the config to use that package and it’s fixed the search.