Queries and Results |
Back | Home | Next |
The Metacat Server provides an interface for searching of metadata stored in the Metacat database.
Steps to perform a query in Metacat
<pathquery version="1.0"> <meta_file_id>unspecified</meta_file_id> <querytitle>unspecified</querytitle> <returnfield>resource/dataset/originator/individualName/surName</returnfield> <returnfield>resource/dataset/originator/individualName/givenName</returnfield> <returnfield>resource/dataset/keywordInfo/keyword</returnfield> <returndoctype></returndoctype> <querygroup operator="UNION"> <queryterm casesensitive="false" searchmode="contains"> <value>%</value> </queryterm> <queryterm casesensitive="false" searchmode="contains"> <value>-//NCEAS//resource//EN</value> <pathexpr>returndoc</pathexpr> </queryterm> <queryterm casesensitive="false" searchmode="contains"> <value>-//NCEAS//eml-dataset//EN</value> <pathexpr>returndoc</pathexpr> </queryterm> </querygroup> </pathquery>
The pathquery document was designed to be flexible enough to query specific fields of any XML document. It also allows the client to specify which fields from a returned document are returned in the initial resultset. Each <returnfield> parameter specifies a field which the DB will return for any query hit. The returndoctype fields allows the client to limit the type of documents to be returned. If left blank, all document types are returned. A <querygroup> creates an AND or an OR statement of the <queryterm>s in the group. The operator can be UNION or INTERSECTION. A <queryterm> defines the actual field against which the query is being performed. The value of the queryterm that we are quering for is encased in <value> tags. The <pathexpr> tag specifies an exact path to which you want to restrict the search. A <pathexpr> tag which contains the keyword returndoc is a special case which is discussed in Packages and Relations.
When the pathquery document is submitted and processed, Metacat returns another XML document called a resultset document.
<resultset> <query> <pathquery version="1.0"> <meta_file_id>unspecified</meta_file_id> <querytitle>unspecified</querytitle> <returnfield>resource/dataset/originator/individualName/surName</returnfield> <returnfield>resource/dataset/originator/individualName/givenName</returnfield> <returnfield>resource/dataset/keywordInfo/keyword</returnfield> <returndoctype></returndoctype> <querygroup operator="UNION"> <queryterm casesensitive="false" searchmode="contains"> <value>%</value> </queryterm> <queryterm casesensitive="false" searchmode="contains"> <value>-//NCEAS//resource//EN</value> <pathexpr>returndoc</pathexpr> </queryterm> <queryterm casesensitive="false" searchmode="contains"> <value>-//NCEAS//eml-dataset//EN</value> <pathexpr>returndoc</pathexpr> </queryterm> </querygroup> </pathquery> </query> <document> <docid>nceas.44.1</docid> <docname>resource</docname> <doctype>-//NCEAS//resource//EN</doctype> <doctitle>Surgras1.txt</doctitle> <createdate>2001-01-12 16:12:06.0</createdate> <updatedate>2001-01-12 16:12:06.0</updatedate> <param name="resource/dataset/keywordInfo/keyword">surfgrass</param> <param name="resource/dataset/keywordInfo/keyword">intertidal</param> <param name="resource/dataset/keywordInfo/keyword">Ventura</param> <param name="resource/dataset/keywordInfo/keyword">Los Angeles</param> <triple> <subject>nceas.46</subject> <relationship>provides table-entity information for package</relationship> <object>nceas.44</object> </triple> <triple> <subject>nceas.45</subject> <relationship>provides eml-physical information for Table</relationship> <object>nceas.46</object> </triple> <triple> <subject>nceas.47</subject> <relationship>provides access control rules for</relationship> <object>nceas.44</object> </triple> <triple> <subject>nceas.47</subject> <relationship>provides access control rules for</relationship> <object>nceas.45</object> </triple> <triple> <subject>nceas.47</subject> <relationship>provides access control rules for</relationship> <object>nceas.46</object> </triple> </document> <document> <docid>nceas.42.1</docid> <docname>resource</docname> <doctype>-//NCEAS//resource//EN</doctype> <doctitle>SLottia.txt</doctitle> <createdate>2001-01-12 16:11:31.0</createdate> <updatedate>2001-01-12 16:11:31.0</updatedate> <param name="resource/dataset/keywordInfo/keyword">lottia</param> <param name="resource/dataset/keywordInfo/keyword">intertidal</param> <param name="resource/dataset/keywordInfo/keyword">Orange</param> <triple> <subject>nceas.41</subject> <relationship>provides table-entity information for package</relationship> <object>nceas.42</object> </triple> <triple> <subject>nceas.40</subject> <relationship>provides eml-physical information for Table</relationship> <object>nceas.41</object> </triple> <triple> <subject>nceas.39</subject> <relationship>provides access control rules for</relationship> <object>nceas.40</object> </triple> <triple> <subject>nceas.39</subject> <relationship>provides access control rules for</relationship> <object>nceas.41</object> </triple> <triple> <subject>nceas.39</subject> <relationship>provides access control rules for</relationship> <object>nceas.42</object> </triple> </document> ..... </resultset>
The first element in the resultset is <query>. Its content is just the pathquery document. The resultset always returns the pathquery document that created it in the <query> tag. The next major tag is <document>. Each XML document returned by the query is represented by a <document> tag. The default document information returned is docid, docname, doctype, doctitle, createdate and updatedate. The param tags are present if the document found contained the returnfield chosen in the pathquery document. The name attribute of the param tag is the full path to the node specified by the returnfield. <relation> tags specify any documents to which the returned document is related. Relations and packages are talked about later.