开发者

Is there a XML meta language for expressing complex search queries?

开发者 https://www.devze.com 2023-01-26 12:29 出处:网络
during the past couple of years a lot of our internal APIs for modifying and searching our database have become more and more entangled with the specific needs and application logic of the front ends

during the past couple of years a lot of our internal APIs for modifying and searching our database have become more and more entangled with the specific needs and application logic of the front ends that they power. To counter that trend we've decided to gradually move those APIs to web services with stable and concisely specified interfaces. Another reason for this step is that the APIs were initially designed for traditional websites while they are now more and more being used by AJAX applications, iPhone apps, external customers an so on.

While working out the details of this process we've realized that one of the major functionalities that we plan on providing are fairly complex searches through various types of resources like, for example, people, documents and locations.

Now, it is obvious that the details of a search largely depend on the search space. There are, however, a lot of meta-concepts that are开发者_JAVA技巧 universal. For instance, logical operators connecting search predicates and a hierarchical structure (braces) and precedence rules for these operations; range queries for numeric values, regular expression matching for strings, and so on. Given these concepts, XML immediately comes to mind as an adequate representation for a query (so do DSLs, but I think that is too big of a gun in our case).

So my question is this: is there an XML meta language on which we can base our own, domain-specific dialect for expression such queries? Or are there other possibilities which have so far not crossed our minds?


The following schema is widely used in GIS world:

  • http://schemas.opengis.net/filter/1.1.0/

Here's an example:

  <ogc:Filter xmlns:gml="http://www.opengis.net/gml">
    <ogc:And>
      <ogc:PropertyIsGreaterThan>
        <ogc:PropertyName>isoap:CreationDate</ogc:PropertyName>
        <ogc:Literal>2007-07-31</ogc:Literal>
      </ogc:PropertyIsGreaterThan>
      <ogc:Or>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>isoap:Type</ogc:PropertyName>
          <ogc:Literal>service</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>isoap:Type</ogc:PropertyName>
          <ogc:Literal>application</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>isoap:Type</ogc:PropertyName>
          <ogc:Literal>dataset</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Or>
    </ogc:And>
  </ogc:Filter>

This can be processed in relational databases as well as document-oriented databases or with full-text indexing like Lucene.


There's XQuery which can be extended with your own functions, etc., but that's not wholly XML-based (it works with XML, but is not itself XML).

0

精彩评论

暂无评论...
验证码 换一张
取 消