Commit Graph

18 Commits

Author SHA1 Message Date
Naz
089edbc39c Added 10k limit to resource queries
refs https://github.com/TryGhost/Team/issues/1665

- When requesting 'all' resource the search could experience significant performance degradation and would be unresponsive when there are large amounts of posts/tags/authors on the site
- The limit of 10 000 records was chosen as a stopgap solution for experiments in live environment. Once we verify this limit is not causing much trouble, we could increase it if neede
2022-07-07 12:58:41 +02:00
Naz
ec68dc303c Removed plaintext formats from posts request
refs https://github.com/TryGhost/Team/issues/1665
refs https://github.com/TryGhost/Ghost/issues/10396

- Content API has been updated to return clean results for `excerpt` without require a hacky "&formats=plaintext" parameter
2022-07-07 12:55:08 +02:00
Naz
df3d6cee74 Swapped elasticlunr with flexsearch
refs https://github.com/TryGhost/Team/issues/1665

- elasticlunr in an abandoned package with quite a lot of security vulnerabilities. it also has worse performance memory/processing wise comparing to flexsearch (benchmark: https://nextapps-de.github.io/flexsearch/bench/)
- fusejs was another option that was consideres. it was not chosed due to it's poor performance.
2022-07-07 12:52:09 +02:00
Naz
11f7e89ee3 Added missing tagsIndex initialization
refs https://github.com/TryGhost/Team/issues/1665

- It is not striclty necessary for the tagsIndex declaration to be in the constructor, but it gives a very clear indication of which variables are a part of the class.
2022-07-07 12:52:08 +02:00
Rishabh
d24ea3ce55 Updated script url to use admin url
refs https://github.com/TryGhost/Team/issues/1665

- replaces usage of site url to admin url as script only needs admin url for setup
- updates tests
2022-07-07 11:09:53 +02:00
Naz
44c8969192 Switched URL calls to use Content API SDK
refs https://github.com/TryGhost/Team/issues/1665

-  The Content API SDK is the recommended way to interact with the API
2022-07-07 09:41:39 +02:00
Naz
09ba52039c Added profile_image property to returned search results
refs https://github.com/TryGhost/Team/issues/1665

-  This piece of data is needed to display author's avatars in search results
2022-07-06 12:34:00 +02:00
Naz
6ccec26a3a Fixed url attribute to returned search results
refs https://github.com/TryGhost/Team/issues/1665

- The url attribute was not indcluded in the doc index
2022-07-06 12:29:54 +02:00
Naz
b6ecad0488 Removed local storage caching
refs https://github.com/TryGhost/Team/issues/1665

- This is a premature optimization that's causing loads of roadblocks while everyone is cracking on the feature (the data format changes, etc.)
- Once we are set on the format and need a performance boost we should design a suitable caching mechanism (the current one does not take resource updates into account, so can cause stale content)
2022-07-06 11:42:06 +02:00
Naz
21a9a4eaba 🐛 Fixed broken index when API returns no results
refs https://github.com/TryGhost/Team/issues/1665

- The search index should be initialized regardless, even if there are no items to put into it the index should be an empty one.
2022-07-06 11:31:23 +02:00
Naz
8b59245893 Added urls to search resources
refs https://github.com/TryGhost/Team/issues/1665

- We need a way to visit the resource found through search. It should not be included in searchable fields though
2022-07-06 11:26:12 +02:00
Naz
592e051485 Connected tags to the search index
refs https://github.com/TryGhost/Team/issues/1665

- Tags should be searchable. This change hooks up the Tags Content API with the search index
2022-07-06 10:56:16 +02:00
Naz
dfc5b1c33d Connected authors to the search index
refs https://github.com/TryGhost/Team/issues/1665

- Authors should be searchable. This change hooks up the Authors Content API with the search index
2022-07-06 10:38:00 +02:00
Naz
df03c47ac1 Search results returning posts as separate attribute
refs https://github.com/TryGhost/Team/issues/1665

- The search results will be handling authors and tags searches as a next step - this change is a groundwork before making this move.
2022-07-05 17:35:29 +02:00
Rishabh
34a3e4ade7 Added redirect for post on search click
- allows click on post result to open it on click when searched
- adds `slug` to content api for data
2022-07-05 17:34:43 +02:00
Naz
b77fee0735 Added post properties to search results
refs https://github.com/TryGhost/Team/issues/1665

- The npm package for elasticlunr does not contain the latest changes (no way to include document properties in search results). This hack adds document properties manually.
- Long term we should think about either helping the maintainer with releases of the library or weight out alternatives like fuse.js (https://fusejs.io)
2022-07-05 16:38:37 +02:00
Naz
d9e9d451c9 Refactored search-index module to use class syntax
refs https://github.com/TryGhost/Team/issues/1665

- The class syntax allows to use constructor DI pattern that helps with unit testing and abstracting away the dependencies
- It wasn't possible to test the internals without having access to the localStorage in tests (you couls access it but that's kind of leaky for tests to know what mechanism is used in the module intenally)
2022-07-05 11:39:11 +02:00
Naz
f6838e2113 Added search index functionality
refs https://github.com/TryGhost/Team/issues/1665
refs 402e54987e/packages/ease/assets/js/main.js (L16-L127)

- This is a React adaptation of the referenced sodo-search functionality
- The module exposes two methods: init and search. Init requires an API URL parameter and an API key; search requires a text value and returns matching search results
2022-07-05 11:38:51 +02:00