Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config option to disable search #5501

Closed
bradystroud opened this issue Jun 14, 2021 · 8 comments
Closed

Config option to disable search #5501

bradystroud opened this issue Jun 14, 2021 · 8 comments
Labels
area: search area: ui/collection good first issue type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@bradystroud
Copy link
Contributor

bradystroud commented Jun 14, 2021

Is your feature request related to a problem? Please describe.
The search functionality does not work for our content. It hits the GitHub API limit after 2 searches. see https://answers.netlify.com/t/cms-search-hitting-github-api-limit/39124

Describe the solution you'd like

  1. A configuration option to disable search entirely so our users don't hit the API limit
    This should be pretty easy to implement
  2. Search that doesn't hit the API limit
    This could be a bit more difficult
@bradystroud bradystroud added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jun 14, 2021
@erezrokah
Copy link
Contributor

Hi @bradystroud, this would make a very good first contribution.

The code that renders the search box is here:
https://github.com/netlify/netlify-cms/blob/2d672834f80da385542dd8ef56dc949f082a50cf/packages/netlify-cms-core/src/components/Collection/CollectionSearch.js#L194

Regarding the search itself - the CMS does cache those entries after the initial search. However if it needs to search 2500 it makes sense it will reach the limit when nothing is cached.

@bradystroud
Copy link
Contributor Author

Hi @erezrokah,
Currently, the search queries every item in the collection. Why can't it just use the search endpoint?https://docs.github.com/en/rest/reference/search#search-code

@erezrokah
Copy link
Contributor

Hi @bradystroud, that's a very good point.
The search in the CMS works a bit different - it reads the files, deserializes the content (e.g. parses the markdown/json/yaml/toml files) into the CMS collections representation (based on the configuration) and search in specific fields:
https://github.com/netlify/netlify-cms/blob/bac132e7f6699fb8c3287c3becb2cc66f09d36a3/packages/netlify-cms-core/src/backend.ts#L592

Using the search API might give good results too pending:

  1. It should work in a similar for all backends (GitLab, Bitbucket, Azure, etc)
  2. Searching the whole content of files still give good results (it might actually give better ones)
  3. We can limit the search per collection using the search API

@bradystroud
Copy link
Contributor Author

Hey @erezrokah,

Please review #5509

Thanks :)

@bradystroud
Copy link
Contributor Author

  1. A configuration option to disable search entirely so our users don't hit the API limit

Done - The config option to disable search is now available.
https://www.netlifycms.org/docs/configuration-options/#search

I am leaving this issue open as further investigation is needed to see if it's possible to have search that doesn't make requests for every entry.
See #5501 (comment) for details on a potential solution to this.

Thanks,

-Brady

@erezrokah
Copy link
Contributor

I am leaving this issue open as further investigation is needed to see if it's possible to have search that doesn't make requests for every entry.
See #5501 (comment) for details on a potential solution to this.

Do you mind opening a new issue for that? I'd rather keep things separate so it's easier to track and follow
Closing this issue as resolved.

@bradystroud
Copy link
Contributor Author

I am leaving this issue open as further investigation is needed to see if it's possible to have search that doesn't make requests for every entry.
See #5501 (comment) for details on a potential solution to this.

Do you mind opening a new issue for that? I'd rather keep things separate so it's easier to track and follow
Closing this issue as resolved.

See #5549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: search area: ui/collection good first issue type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

2 participants