简体   繁体   English

我应该在客户端或服务器上实现我的搜索引擎字符串解析器吗?

[英]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. 我有一个html输入,通过ajax调用发送查询字符串到我的PHP服务器。 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? 搜索字符串可能很复杂并允许过滤器,我的实现问题是寻求反馈,我应该处理客户端字段/值的解析并动态添加post值还是应该处理服务器端的所有内容?

Example: From the search box you could enter things such as 示例:在搜索框中,您可以输入诸如

'search string category:sports submitted:today'

Then I could either 然后我也可以

javascript submits javascript提交

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

server parses to 服务器解析为

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

OR 要么

javascript parses and submits javascript解析并提交

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

server handles post parameters 服务器处理post参数

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

我会选择方式1,因为服务器和客户端之间的交互最小。

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. 但它可能不是最佳的应用行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM