Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

should I implement my search engine string parser on client or server?

I have an html input that sends the query string through an ajax call to my php server. The search string can be complex and allow for filters, my implementation question looking for feedback is should I handle the parsing of the fields/values on the client side and dynamically add post values or should I handle everything on the server side?

Example: From the search box you could enter things such as

'search string category:sports submitted:today'

Then I could either

javascript submits

(POST) q='search string category:sports submitted:today' 

server parses to

query='search string' 
category='sports' 
submitted'today' 

OR

javascript parses and submits

(POST) q='search string'
(POST) category='sports'
(POST) submitted='today' 

server handles post parameters

query='search string' 
category='sports' 
submitted='today' 
like image 557
user391986 Avatar asked Mar 27 '26 19:03

user391986


2 Answers

Depends on how interactive you want your application to be.

IF the client parses it while the user is typing, you could provide auto-fill features and validation. Else you have to wait for the user to be done and then receive feedback from the server.

Technically it is not a big deal for the server-side to parse. But it just may not be the optimum application behavior.

like image 175
Master Chief Avatar answered Mar 30 '26 11:03

Master Chief


I would choose way 1 because of minimum interactions between server and client.

like image 30
Alex Avatar answered Mar 30 '26 11:03

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!