What is the best practice to search backend?


#1

@leob, @coreelements, @JerryBels, @KazekageGaara I m using Ionic + Elastic Search combo. What is the best practice for search?

  1. Go and reach to the server for every character typed by the user & get the results accordingly.
  2. Get the results from the Elastic Search Server when the user typed first character and then filter it in the client side for any upcoming expressions. Example, If user types letter I, reach to server & get the results back. Server gives everything starting with letter I, secondly if user types characters IO, don’t go to server. Just filter it in the client side with the results given back by the server.

#2

hmm good one …

you could go with option 1 … but … only send the query after like 10 milliseconds after the user stopped typing. So this way you can still reduce the amount of server calls :slight_smile:

Option 2 … it’s a nice idea … it might work, but if the server is to occupied or you have A LOT of words starting with I … the user has to wait.

Or maybe you can combine option 1 (with the miliseconds wait) with option 2


Ionic + Elastic Search
#3

Option 2 means get the whole dataset from the server? That sounds impractical.

I think option 1 (incremental search with multiple roundtrips to the server) is the only practical way, but i would use Debounce on the model options, e.g:

<input type="search"
                   placeholder="Type words"
                   ng-change="vm.searchWords()"
                   ng-model="vm.data.search"
                   ng-model-options="vm.modelOptions">

and then:

  // Use debounce for efficiency, see: https://www.airpair.com/angularjs/posts/ngmodeloptions-total-model-control
  vm.modelOptions = {
    updateOn: 'default blur',
    debounce: {
      default: 500,
      blur: 0
    }
  };

The delay here is set at 500 ms (half a second) which I think is responsive enough, 10ms is way too short.


#4

what @leob said :smile:

option 1 … use 500ms


#5

ok :grinning: I m happy for the response back @leob @coreelements. what would be the right approach to create indexes in elastic search server? My words are in different backend. If I add new set of words to that backend, how to sync words between db and elastic search server?


#6

I’ve heard about elastic search but I have no experience with it …

In the future I can imagine that my project could benefit from a search function through ElasticSearch but not now.


#7

“I’ve heard about elastic search but I have no experience with it …” … same as me