0

An "AnyText" filter for "%opendata%" takes over 300 seconds so proxy closes my connection.

An "apiso:KeywordType" filter for "%opendata%" gives 0 results which makes sense because I do not what the type but I want to search in keywords!

What can I do? Thanks.

Edit: Answered my own question with python.

  • Looks like apiso:Subject does the job. – uav Feb 20 '14 at 14:14
  • 1
    In order to make it easier to other to help you, can you provide the link to the search form. – magdmartin Feb 20 '14 at 17:23
1

The following python 2.7 code...

# -*- coding: utf-8 -*-

import requests

def main():

    get_records = """<?xml version="1.0" encoding="UTF-8"?>
<GetRecords
    xmlns="http://www.opengis.net/cat/csw/2.0.2"
    xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:ows="http://www.opengis.net/ows"
    xmlns:dct="http://purl.org/dc/terms/"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:gmd="http://www.isotc211.org/2005/gmd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    service="CSW"
    version="2.0.2"
    maxRecords="{max_records}"
    startPosition="1"
    resultType="results"
    outputFormat="application/xml"
    outputSchema="http://www.isotc211.org/2005/gmd"
    xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
    <Query typeNames="gmd:MD_Metadata">
        <ElementSetName typeNames="csw:IsoRecord">full</ElementSetName>
        <csw:Constraint version="1.1.0">
            <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
                <ogc:PropertyIsLike wildCard="%" singleChar="_" escapeChar="\">
                    <ogc:PropertyName>apiso:Subject</ogc:PropertyName>
                    <ogc:Literal>%opendata%</ogc:Literal>
                </ogc:PropertyIsLike>
            </ogc:Filter>
        </csw:Constraint>
    </Query>
</GetRecords>""".format(max_records = 1) # minimal 1 !

    r = requests.post('http://gdk.gdi-de.org/gdi-de/srv/eng/csw', data=get_records, headers={'content-type': 'application/xml'})

    xml_string = r.content

    with open('for_opendata_stackexchange_com___output.txt', 'w') as file_out:
        file_out.write(xml_string)

if __name__ == '__main__':
    main()

...will result in a text file starting with...

<?xml version="1.0" encoding="UTF-8"?>

<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">

  <csw:SearchStatus timestamp="2014-02-23T21:03:24" />

  <csw:SearchResults numberOfRecordsMatched="1053" numberOfRecordsReturned="1" elementSet="full" nextRecord="2">
...

So the German geo data catalogue has 1053 open data sets.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.