ElkArte Community

Extending Elk => Addons => Topic started by: emanuele on September 20, 2014, 01:10:48 pm

Title: [ADDON] [WIP] Live search
Post by: emanuele on September 20, 2014, 01:10:48 pm
Lurking around, I noticed an interesting idea, so I decided to give it a try.
For the moment it's just a bunch of code not yet fully working, so I'll keep the code for myself until finished, but I can share a picture (see attachment).

The idea is to use the search box at the top to return results "live" while typing.
Of course we all know that the search is one of the most demanding functions, so install this addon could easily kill your server if any of your users or guests may decide to play you a trick.

For the record I'm not using Elk's search function, I decided (at least for the moment), to use a simple query with a LIKE on just the subjects. Of course I have no idea if this creates more or less problems to the server (any hint is welcome!).

Client-side I decided to use Angularjs again.

Before the release I'll try to think about ways to avoid abuse of the function, even though it's quite difficult because the "live" part is the only attractive one... well, for the moment it's not very important, and even later I may just suggest you not to install the addon or to remove it if your server dies. :P

P.S.
The magnify lens instead of "search" may be something to consider for the "core", though... O:-)
Title: Re: [ADDON] [WIP] Live search
Post by: Mstcool on September 20, 2014, 01:13:42 pm
Very nice :)
Title: Re: [ADDON] [WIP] Live search
Post by: meetdilip on September 20, 2014, 02:42:01 pm
Brilliant @emanuele . Never seen it in any popular forum script.
Title: Re: [ADDON] [WIP] Live search
Post by: Spuds on September 20, 2014, 03:25:05 pm
Cool idea  :D
Quote from: emanuele – The idea is to use the search box at the top to return results "live" while typing.
Of course we all know that the search is one of the most demanding functions, so install this addon could easily kill your server if any of your users or guests may decide to play you a trick.

For the record I'm not using Elk's search function, I decided (at least for the moment), to use a simple query with a LIKE on just the subjects. Of course I have no idea if this creates more or less problems to the server (any hint is welcome!).
A simple like is not going to have any relevancy to the hits, I suppose you could do a recent first since a subject only search is not very accurate anyway.  Personally I feel you are a lot better off  (a lot better off) using the built in search functions for a variety of reasons.
Quote from: emanuele – Client-side I decided to use Angularjs again.
Still something I've never used, maybe someday, but my stack is full so something would have to drop off :P
Quote from: emanuele – Before the release I'll try to think about ways to avoid abuse of the function, even though it's quite difficult because the "live" part is the only attractive one... well, for the moment it's not very important, and even later I may just suggest you not to install the addon or to remove it if your server dies. :P
Certainly a permissions setting would be good, along with a more restrictive searches per time limit (maybe no error, it just acts normally at if inside the limit)
Quote from: emanuele –
P.S.
The magnify lens instead of "search" may be something to consider for the "core", though... O:-)
+1 !
Title: Re: [ADDON] [WIP] Live search
Post by: emanuele on September 20, 2014, 05:51:32 pm
Quote from: Spuds – A simple like is not going to have any relevancy to the hits, I suppose you could do a recent first since a subject only search is not very accurate anyway.  Personally I feel you are a lot better off  (a lot better off) using the built in search functions for a variety of reasons.
Yep, I have the feeling that kind of search is not very relevant, it gives some results hopefully without much overload, though it's just basically random.
I'll have a look at using the built in functions. :D

Quote from: Spuds –
Quote from: emanuele – Client-side I decided to use Angularjs again.
Still something I've never used, maybe someday, but my stack is full so something would have to drop off :P
LOL
It's actually rather "simple" (unless you want to do complex things of course).
It cannot be directly compared to jQuery, though it feels easier to use and more "straightforward" (especially in the sense that it gives you a clear direction on how to do things).
I started with that course:
https://www.codeschool.com/courses/shaping-up-with-angular-js

Quote from: Spuds – Certainly a permissions setting would be good, along with a more restrictive searches per time limit (maybe no error, it just acts normally at if inside the limit)
Maybe also a token may help, in order to ensure that who is searching is actually doing it from the webpage, or at least close to it.

Quote from: Spuds –
Quote from: emanuele – P.S.
The magnify lens instead of "search" may be something to consider for the "core", though... O:-)
+1 !

/me tracks the +1 O:-)
Title: Re: [ADDON] [WIP] Live search
Post by: emanuele on October 01, 2014, 05:12:29 pm
Okay, pushed the first commit that uses the "custom search":
https://github.com/emanuele45/LiveSearch
Title: Re: [ADDON] [WIP] Live search
Post by: Spuds on October 01, 2014, 08:26:35 pm
Very cool  8)