4 Replies Latest reply on Jul 13, 2007 7:14 AM by 586185

    Filter REGEX in SDO_RDF_MATCH

    586185
      Hello;

      I want to know how to use the regex, like or similar under the SDO_RDF_MATCH. I only see examples with simple conditions 'h < 5' etc..

      Regards

      Isidro
        • 1. Re: Filter REGEX in SDO_RDF_MATCH
          Mannamal-Oracle
          A lot of such operations can be done using a WHERE clause outside of SDO_RDF_MATCH. For example:

          SELECT x Male
          FROM TABLE(SDO_RDF_MATCH( '(?x rdf:type :Male)',
          SDO_RDF_Models('family'),
          null, SDO_RDF_Aliases(SDO_RDF_Alias('','http://www.example.org/family/')), null))
          WHERE x LIKE '%T%';

          Melli
          • 2. Re: Filter REGEX in SDO_RDF_MATCH
            586185
            Hello;

            I think it so, but the question is about the last parameter 'filter condition' of SDO_RDF_MATCH.
            1.- If you work with namespaces, you cannot tell directly about elements in them,.. well, without using regular expressions.

            In your example;
            SELECT x Male
            FROM TABLE(SDO_RDF_MATCH( '(?x rdf:type :Male)',
            SDO_RDF_Models('family'),
            null, SDO_RDF_Aliases(SDO_RDF_Alias('','http://www.example.org/family/')), null)) WHERE x LIKE '%T%';

            if this alias the preffix, 'family'
            <b>SDO_RDF_Alias('family','http://www.example.org/family/'</b>

            in this <b>WHERE</b> you cannot express the clause <b>LIKE 'family:Jo' </b> because out of this query the result is
            http://www.example.org/family/John

            2.- The FILTER parameter is in most cases however it is more efficient to include it as part of SDO_RDF_MATCH SDO_RDF_MATCH what arguments can be filtered?

            3.- Then, I tell again the question, Can I use the clause LIKE of similar into SDO_RDF_MATCH to filter string based results.

            Best

            Isidro
            • 3. Re: Filter REGEX in SDO_RDF_MATCH
              Mannamal-Oracle
              Yes, regular expressions can be used as well - essentially any expression that can be used in a WHERE clause can be used in the filter clause.

              However, there might be some issues related to typing, since what is retrieved from SDO_RDF_MATCH can be of multiple types. We are planning on a document that describes how the filter clause can best be used.

              Meanwhile, here is a simple example of using REGEXP_LIKE in the filter clause. You would of course have to write a more complex expression for the kinds of filtering you would like to do.


              SELECT x Male
              FROM TABLE(SDO_RDF_MATCH( '(?x rdf:type :Male)',
              SDO_RDF_Models('family'),
              null, SDO_RDF_Aliases(SDO_RDF_Alias('','http://www.example.org/family/')), 'REGEXP_like(x, ''Jack'')'));
              • 4. Re: Filter REGEX in SDO_RDF_MATCH
                586185
                Hello;

                Yes, this is all I want. I was very confussed with the syntax.

                Thank you

                Best

                Isidro