Ignore local parameter for non localized content types
drazik opened this issue · comments
I would like to search in two content types: one is localized, but not the other. I have the following configuration:
"fuzzy-search": {
enabled: true,
config: {
contentTypes: [
{
uid: "api::molecule.molecule",
modelName: "molecule",
fuzzysortOptions: {
characterLimit: 500,
threshold: -1000,
limit: 15,
keys: [
{
name: "casNumber",
weight: 100,
},
{
name: "name",
weight: 100,
},
],
},
},
{
uid: "api::page.page",
modelName: "page",
fuzzysortOptions: {
characterLimit: 500,
threshold: -1000,
limit: 15,
keys: [
{
name: "title",
weight: 100,
},
],
},
},
],
},
},
molecule
is not localized, but page
is localized. When I send a request to http://localhost:1337/api/fuzzy-search/search?query=test&locale=fr
, I get the following response:
{
"data": null,
"error": {
"status": 400,
"name": "ValidationError",
"message": "A query for the locale: 'fr' was found, however model: 'molecule' is not a localized content type. Enable localization if you want to query or localized entries.",
"details": {}
}
}
Is it possible to configure the plugin to ignore the locale
parameter in the non-localized content types?
Hey @drazik,
thank you for bringing this up. It is not possible at the moment, but I'll try to add a way to query the locale scoped to a content type asap.
Hey @drazik ,
just had a look at the problem you are facing. I suggest you just drop the locale
query parameter and instead filter for the locale of a given contentType. That should work 🙂.
e.G.:
http://localhost:1337/api/fuzzy-search/search?query=whatever&filters[books][locale]=en
.
I will add a disclaimer to the Readme, however, that the locale as a "global" query parameter expects all content types to be available in the locale.
Readme updated in v2.0.3