简体   繁体   English

在数据库中存储过滤条件

[英]Storing filter criteria in database

I have an web application with Javascript based UI and Jersey based REST service. 我有一个基于Javascript的UI和基于Jersey的REST服务的Web应用程序。 The UI has certain features requiring complex search criteria to retrieve the data. UI具有某些功能,需要复杂的搜索条件才能检索数据。 The UI defines the search criteria with various parameters but the most significant to this discussion is this. UI用各种参数定义了搜索条件,但是对本次讨论最重要的是这一点。 A user can create a filter like this- 用户可以创建这样的过滤器-

 1. (     Receiver_Email_ID           CONTAINS         xyz@abc.com                  AND

 2.       Sender_Email_ID             CONTAINS         blocked@abc.com         )    OR

 3. (     Origin_Domain                  IS            BADDOMAIN.com                AND

 4.       Email_has_attachment           ==            true                    )

The numbers 1 to 4 just indicate that these are different rows in the UI and that the sequence matters here. 数字1到4仅表示这些是UI中的不同行,并且这里的顺序很重要。 The UI represents it in JSON format which on the server could be received as a POJO. UI以JSON格式表示,可以在服务器上以POJO的形式接收。 I need the ability to store this criteria such that the UI can be repopulated with the filter and it could be executed. 我需要能够存储此条件,以便可以使用过滤器重新填充UI并可以执行该UI。 Along with several other tables, I plan to use the following database table to store this- 与其他几个表一起,我计划使用以下数据库表来存储该表-

rule_id
rule_seq
op_paren
left_opr
operator
right_opr
cl_paren
and_or

Does it look right or I can improve it? 它看起来正确还是我可以改善它? The other option I have is to store the entire JSON in an embedded document DB such as OrientDB. 我的另一个选择是将整个JSON存储在嵌入式文档数据库(例如OrientDB)中。

From formal point of view each search criteria is Abstract syntax tree It's don't fit you structure. 从形式上看,每个搜索条件都是抽象语法树。它不适合您的结构。 You idea about saving search in OrientDB is very fit to task from this point of view but realization not simple. 从这个角度来看,您关于在OrientDB中保存搜索的想法非常适合任务,但实现起来并不简单。

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

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