{"action":"created","issue":{"url":"https://api.github.com/repos/TryGhost/Ghost/issues/5321","repository_url":"https://api.github.com/repos/TryGhost/Ghost","labels_url":"https://api.github.com/repos/TryGhost/Ghost/issues/5321/labels{/name}","comments_url":"https://api.github.com/repos/TryGhost/Ghost/issues/5321/comments","events_url":"https://api.github.com/repos/TryGhost/Ghost/issues/5321/events","html_url":"https://github.com/TryGhost/Ghost/issues/5321","id":80209694,"node_id":"MDU6SXNzdWU4MDIwOTY5NA==","number":5321,"title":"[Discussion] Solving Search in Ghost?","user":{"login":"ErisDS","id":101513,"node_id":"MDQ6VXNlcjEwMTUxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/101513?v=4","gravatar_id":"","url":"https://api.github.com/users/ErisDS","html_url":"https://github.com/ErisDS","followers_url":"https://api.github.com/users/ErisDS/followers","following_url":"https://api.github.com/users/ErisDS/following{/other_user}","gists_url":"https://api.github.com/users/ErisDS/gists{/gist_id}","starred_url":"https://api.github.com/users/ErisDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ErisDS/subscriptions","organizations_url":"https://api.github.com/users/ErisDS/orgs","repos_url":"https://api.github.com/users/ErisDS/repos","events_url":"https://api.github.com/users/ErisDS/events{/privacy}","received_events_url":"https://api.github.com/users/ErisDS/received_events","type":"User","site_admin":false},"labels":[{"id":99328002,"node_id":"MDU6TGFiZWw5OTMyODAwMg==","url":"https://api.github.com/repos/TryGhost/Ghost/labels/help%20wanted","name":"help wanted","color":"009800","default":true},{"id":82875520,"node_id":"MDU6TGFiZWw4Mjg3NTUyMA==","url":"https://api.github.com/repos/TryGhost/Ghost/labels/server","name":"server","color":"0B939C","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":81,"created_at":"2015-05-24T16:54:34Z","updated_at":"2018-06-21T16:37:12Z","closed_at":null,"author_association":"MEMBER","body":"The issue to add [Search to the Posts API](https://github.com/TryGhost/Ghost/issues/306), is literally the oldest open issue in this repository. It’s a specialist subject, so we’ve always hoped someone with specialist knowledge would come forward to help us solve it, but unfortunately that hasn’t happened.\n\nTo try to increase visibility of the problem we set up a page advertising [contributor roles](https://ghost.org/contribute/search-lead/) - detailing that we were looking for someone to help solve adding search to Ghost. That didn’t work either :(\n\nUnfortunately, adding search is a particularly complex challenge. This is another attempt to try to get engagement from the wider OSS community on how to do this - we’d really appreciate the opinions and input of anyone who knows their search-fu.\n\n---\n## Use cases\n\nThere are two key use cases for search inside of Ghost itself - one being in the admin panel to find a post, tag, user or perhaps even a setting that you want to change. This would make a significant improvement to the usability the admin interface. \n\nThe other is adding search to the frontend of a blog, so that it becomes easier to find content. The main things that need to be searchable are post titles and content, tag names and description, user names, and probably meta titles and descriptions for the different resources. There are plenty of use cases where other things would also need to be searchable, so this will need to be extensible, but these are the key fields.\n## Approaches\n\nThe best way to make both of these use cases possible, as well as making the search feature available to any apps or other extensions of Ghost in future, is to make it available through the API. \n\nThere are generally two approaches to solving search that would work in Ghost that I am aware of - the first being to use the FTS features of SQL and the second being to use a third party search tool of some description. \n\nThe upside to FTS is that, if we get it working well, it could work for all Ghost installs without any need to install additional (and likely complex) dependencies. The downside is that getting FTS to work for all three of sqlite, MySQL and PG is a sizeable challenge & the [status of FTS in knex is unknown](https://github.com/tgriesser/knex/issues/203) - but perhaps it can be done as a bookshelf/knex plugin, in a way that will benefit the wider community as well?\n\nThe upside to using a 3rd party tool, is that there are many modern and advanced systems that we could leverage to make an exceptional search feature. The downside is that most of them require additional complex dependencies* to be installed, which mean they aren’t viable options for Ghost core. \n\nOne of the tools that has been recommended is lunr.js, and there is a [plugin for Ghost themes](https://github.com/jamalneufeld/ghostHunter) which combines lunr & the RSS feed to make search possible on the frontend. Supposedly lunr also works in node, not just the browser, but I’ve not found much information about it.\n\nOther tools that are popular for search include lucene and elasticsearch and there are also numerous modules for node built on top of leveldb and redis databases. There are likely solutions out there that I haven’t heard about, so I’d be interested to hear ideas from others.\n\n\\* complex dependencies includes binaries or external services - Ghost is currently installable on almost any platform without too much fiddling with compilers etc, and we want to keep it that way!\n## Moving forward\n\nThe ideal solution, in my mind, looks something like:\n- Have a rudimentary version of search built into Ghost via the API - using FTS or something else - that will work for 90% of blogs (i.e. relatively small amounts of content).\n- Implement this version of search to be easily extensible, so that it’s very easy to create an app that replaces the search with something more heavy-duty like elastic search or lucene, to support larger blogs. \n## The immediate future\n\nAs part of Zelda, we want to introduce a search bar to the admin interface which provides auto-complete style results for posts, tags and users. This should be possible using our existing API, some minor modifications (to allow us to fetch certain fields) and Ember. It’s not ideal, but I think something incredibly rudimentary is better than nothing at all! This will be spec’d in a separate issue.\n## Continuing this discussion\n\nI’m really, really looking for the community to get involved and share their ideas here. This is a relatively specialist subject and I know there are tonnes of developers out there that have a great deal more experience implementing search than I do. \n\nI’d like to hear thoughts, ideas and experiences on FTS - will we be able to make it work for all 3 databases without having to write too much custom code? Could a bookshelf plugin work? Is it an absolute nightmare not worth pursuing?\n\nWhat about lunr? Is it a viable server-side option? Does it have too many requirements or not work for large data sets, or is it the perfect basic option provided it can easily be overridden with elastic search or something else?\n\nIs there another solution that isn’t mentioned here? Remember we can’t have leveldb or redis or other complex dependencies in core and it has to work across sqlite3, mysql and postgres.\n\nAnd what about the API? What would a good search API look like? Who out there has a great RESTful search API that we should take inspiration from?\nIf you know someone you think could answer any of these questions, please link them here and ask them to get involved!\n\nThanks :)\n"},"comment":{"url":"https://api.github.com/repos/TryGhost/Ghost/issues/comments/399167119","html_url":"https://github.com/TryGhost/Ghost/issues/5321#issuecomment-399167119","issue_url":"https://api.github.com/repos/TryGhost/Ghost/issues/5321","id":399167119,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTE2NzExOQ==","user":{"login":"jozic","id":124249,"node_id":"MDQ6VXNlcjEyNDI0OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/124249?v=4","gravatar_id":"","url":"https://api.github.com/users/jozic","html_url":"https://github.com/jozic","followers_url":"https://api.github.com/users/jozic/followers","following_url":"https://api.github.com/users/jozic/following{/other_user}","gists_url":"https://api.github.com/users/jozic/gists{/gist_id}","starred_url":"https://api.github.com/users/jozic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jozic/subscriptions","organizations_url":"https://api.github.com/users/jozic/orgs","repos_url":"https://api.github.com/users/jozic/repos","events_url":"https://api.github.com/users/jozic/events{/privacy}","received_events_url":"https://api.github.com/users/jozic/received_events","type":"User","site_admin":false},"created_at":"2018-06-21T16:37:12Z","updated_at":"2018-06-21T16:37:12Z","author_association":"NONE","body":"@pascalandy \r\nthings i don't like\r\n- when you select an item from the list, before opening the post it puts selected item as json in search field (minor)\r\n- sometimes it will not open an item, not very often, but it's not great experience for sure\r\n\r\nalso it loads all posts and does search on client side, which won't scale (but I'm not at that scale yet)\r\n\r\notherwise, it works fine\r\n\r\n"}}
{"actor":{"display_login":"jozic"}}