strapi-plugin-fuzzy-search icon indicating copy to clipboard operation
strapi-plugin-fuzzy-search copied to clipboard

Feature Request - Customizable Field Selection and Content Type Population

Open tobiratzberger opened this issue 1 year ago • 3 comments

Hey there!

I've been using the fuzzy-search plugin and found it to be a fantastic tool for searching through content. However, I believe there's room for improvement by allowing users to define the fields to be returned and by introducing a more efficient way to handle complex queries through content type population.

Feature Request 1: Customizable Field Selection

Currently, the fuzzy-search plugin returns all fields for a given content type. While this can be useful, there are situations where we only need specific fields for our search results. To address this, I suggest introducing a feature that allows users to define the fields to be returned, providing more control and potentially improving performance on content types with a large number of fields.

Here's an example of how the configuration could look:

// ...
{
    uid: "api::book.book",
    modelName: "book",
    fields: ["name", "description"],
    fuzzysortOptions: {
        // ...
    },
},
// ...

Feature Request 2: Content Type Population for Complex Queries

Building complex queries can be a time-consuming and error-prone process. To simplify this, why not allow users to define content type populations directly within the search configuration? This would serve as a base configuration that can be extended when querying search results, making it much more convenient and reducing the need to build complex queries repeatedly.

Here's an example of how this could work:

// ...
{
    uid: "api::book.book",
    modelName: "book",
    fields: ["name", "description"],
    populate: {
        authors: {
            // - maybe also allow fields here too?
            populate: {
                city: true
            }
        }
    },
    fuzzysortOptions: {
        // ...
    },
},
// ...

These two feature requests would greatly enhance the flexibility and usability of the fuzzy-search plugin, making it even more valuable for developers working with large and complex datasets.

I hope you find these suggestions helpful and consider implementing them in future updates. Thank you for your continued efforts to improve the plugin!

Best regards, Tobi

tobiratzberger avatar Jan 24 '24 19:01 tobiratzberger

First of all thanks you to the author @DomDew, for making this plugin. This works well with all the general expectations with searching.

@tobiratzberger, I was also looking for the same where I could pass "fields" query parameters in REST API to fetch only those specific fields of a content type. But I think this is not available as of now. Yes I do believe it should improve the fetch performance.

nishk02 avatar Mar 12 '24 07:03 nishk02

+1 on being able to select fields, our responses are huge because of populated data and json fields.

gregg-cbs avatar Apr 11 '24 10:04 gregg-cbs

Hey @tobiratzberger, thank you for opening this detailed feature request! I think both of these features would be very nice additions. I'm a bit short on time at the moment though, so things will definitely take some time. If these features are important to you please feel free to open a PR, they are always welcome! 🙂

DomDew avatar Jul 17 '24 08:07 DomDew