H
H
hackuun2018-04-20 18:37:27
JavaScript
hackuun, 2018-04-20 18:37:27

How to implement site search?

What are the options and ways to implement search on the site?
The front uses Vue. On the backend, the API server on Node, returning JSON, the Mongo database (plus a Redis dock, if necessary).
I looked through 30 pages in the Github search and did not find anything suitable, or I'm looking at something wrong.
Initial requirements are approximately the following:
1. Self-hosted Open Source solution. Those. no cloud services.
2. A simple search will do to start with, such as the titles of articles. Those. the user types a word, I look for it in all the headings of all the articles that are in the database and return matches to it.
3. If there are any ready-made tested modules, then autocomplete is required.
4. At the front, it should look like this: the user types a word, and when he has already typed, say, 5 characters, then I return the options to him in a pop-up message under the search field.
I guess I need a solution for both the backend and the front?
What is the general principle of implementation of this?
Also additional questions:
1. Am I right in thinking that Algolia is a completely cloud-based solution? What is the principle of work there, if everything is stored in my database? Do I need to transfer everything there and depend on them completely? What then does this bible do? https://github.com/algolia/instantsearch.js Judging by the fact that the API key is working, does it take the data from the Algolia cloud?
2. Elasticsearch is generally from another opera, only for logs? Or not? What specific tasks does it perform in this context and how can it be useful?
3. If we go the easy way and start to deal with typeahead.js, then what needs to be implemented on the backend? Judging by their example on twitter.github.io/typeahead.js , there is a request for /search?q=hello on input and JSON with 20 objects is returned. It turns out that I need to make a controller on the server, which will simply make constant requests to the database? Or just keep absolutely all the necessary information somewhere in memory (headlines and content of articles, for example) and search the entire text with JS and return matches? How is it done correctly?
During the research on Github, this was found.
https://github.com/algolia/instantsearch.js // Algolia only???
https://github.com/algolia/vue-instantsearch // only with Algolia???
Frontend, Autocomplete:
https://github.com/twitter/typeahead.js // ideally this should work
https://github.com/LeaVerou/awesomplete // does this seem to work when all the data is already on the client?
https://github.com/bevacqua/horsey
https://github.com/algolia/autocomplete.js// Algolia again. does it only work with them?
https://github.com/santiblanko/vue-instant
Fuzzy Search:
https://github.com/krisk/Fuse
https://github.com/farzher/fuzzysort
https://github.com/mattyork/fuzzy
https://github.com/bevacqua/fuzzysearch
Backend:
https://github.com/tj/reds // is this by or for my purpose?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Beach, 2018-04-20
@hackuun

1) Take or make an autocomplete component. It is done simply, at times it is easier to do than to customize something that exists. It is done really simply.
2) The autocomplete component, when entering a certain number of characters, sends a request to the server. If the characters are printed, the previous sent request is interrupted (debounce is called such garbage).
3) The server, in response to the phrase, makes a request to the database and pulls out the data. How it pulls out - the fuzzy search you mentioned (most often based on the Levenshtein distance), full / partial match, another option that will match the phrase and certain records from the database. ElasticSearch - if I'm not mistaken for those options when you need a search in the text of the article. In response, the name of the article and the identifier of the article or the entire article are sent. The entire article or identifier - optional, depending on the size of the articles.
4) After the response came from the server - vuejs, when selected from the autocomplete list, displays the article or loads it by ID, or something else similar.
Everything is simple and easy and is written independently. Somehow a day was spent looking for ready-made options, as a result of which something relatively good was found, weighing a lot, "attached to the current project with electrical tape." Then, in half a day, my own version was written, which worked faster and weighed less and was easily tuned to current tasks.

V
vanyamba-electronics, 2018-04-20
@vanyamba-electronics

Look here . We used RiSearch Pro, works great, my recommendation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question