<jupyter_start><jupyter_text>Search and retrieveSearch for "platypus" and examine results.<jupyter_code># include some utility data and methods
import notebook_utils as nbu

import json
from d1_client import cnclient_2_0

cn_base_url = "https://cn.dataone.org/cn"
print("Using base url of: {0}\n".format(cn_base_url))

cncli = cnclient_2_0.CoordinatingNodeClient_2_0(base_url=cn_base_url)

query_engine = "solr"
base_path = "/"
term = "platypus"
query = f"text:%{term}% AND formatType:METADATA"
params = {
    "start":0,
    "count":10,
    "q":query,
    "wt":"json",
    "fl":"id,dateModified,dataSource,title,abstract"
}
res = cncli.queryResponse(query_engine, base_path, vendorSpecific=None, do_post=False, params=params)
print(f"URL sent to server: {res.url}")
results = json.loads(res.text)
print("Response JSON:")
print(nbu.nLines(json.dumps(results, indent=2), max_lines=50))<jupyter_output>Using base url of: https://cn.dataone.org/cn

URL sent to server: https://cn.dataone.org/cn/v2/query/solr/?start=0&count=10&q=text%3A%25platypus%25+AND+formatType%3AMETADATA&wt=json&fl=id%2CdateModified%2CdataSource%2Ctitle%2Cabstract
Response JSON:
{
  "responseHeader": {
    "status": 0,
    "QTime": 4,
    "params": {
      "q": "text:%platypus% AND formatType:METADATA",
      "fl": "id,dateModified,dataSource,title,abstract",
      "start": "0",
      "count": "10",
      "wt": "json"
    }
  },
  "response": {
    "numFound": 68,
    "start": 0,
    "docs": [
      {
        "id": "AKCRRAB.8.1",
        "dateModified": "2015-01-06T13:19:19.888Z",
        "title": "2011 BKC larval rearing survival"
      },
      {
        "id": "aekos.org.au/collection/tas.gov.au/platypus.20170511",
        "dateModified": "2018-08-03T02:08:12.346Z",
        "abstract": "The fungal disease mucormycosis, caused by the fungal pathogen Mucor amphibiorum, has infected Tasmanian platypus for almost thr[...]<jupyter_text>Resolve an itemUse the `CN.resolve()` method to get the URL for the third item in the response.<jupyter_code>identifier = results["response"]["docs"][2]["id"]
print(f"Resolving identifier: {identifier}")
res = cncli.resolve(identifier)
print(nbu.asXml(res))<jupyter_output>Resolving identifier: aekos.org.au/collection/tas.gov.au/platypus.20180628
<?xml version="1.0" ?>
<ns1:objectLocationList xmlns:ns1="http://ns.dataone.org/service/types/v1">
  <identifier>aekos.org.au/collection/tas.gov.au/platypus.20180628</identifier>
  <objectLocation>
    <nodeIdentifier>urn:node:CN</nodeIdentifier>
    <baseURL>https://cn.dataone.org/cn</baseURL>
    <version>v1</version>
    <version>v2</version>
    <url>https://cn.dataone.org/cn/v2/object/aekos.org.au%2Fcollection%2Ftas.gov.au%2Fplatypus.20180628</url>
  </objectLocation>
  <objectLocation>
    <nodeIdentifier>urn:node:mnUNM1</nodeIdentifier>
    <baseURL>https://mn-unm-1.dataone.org/knb/d1/mn</baseURL>
    <version>v1</version>
    <version>v2</version>
    <url>https://mn-unm-1.dataone.org/knb/d1/mn/v2/object/aekos.org.au%2Fcollection%2Ftas.gov.au%2Fplatypus.20180628</url>
  </objectLocation>
  <objectLocation>
    <nodeIdentifier>urn:node:TERN</nodeIdentifier>
    <baseURL>https://dataone.tern.org.au/mn</bas[...]<jupyter_text>Retrieve the itemRetrieve the item from the node and show the object.<jupyter_code>doc = cncli.get(identifier)
print(doc.text)<jupyter_output><?xml version="1.0" encoding="UTF-8"?>
<eml:eml packageId="aekos.org.au/collection/tas.gov.au/platypus.20180628" system="aekos" xmlns:acc="eml://ecoinformatics.org/access-2.1.1" xmlns:att="eml://ecoinformatics.org/attribute-2.1.1" xmlns:cit="eml://ecoinformatics.org/literature-2.1.1" xmlns:dat="eml://ecoinformatics.org/dataTable-2.1.1" xmlns:doc="eml://ecoinformatics.org/documentation-2.1.1" xmlns:ds="eml://ecoinformatics.org/dataset-2.1.1" xmlns:eml="eml://ecoinformatics.org/eml-2.1.1" xmlns:ent="eml://ecoinformatics.org/entity-2.1.1" xmlns:md="eml://ecoinformatics.org/methods-2.1.1" xmlns:phys="eml://ecoinformatics.org/physical-2.1.1" xmlns:proj="eml://ecoinformatics.org/project-2.1.1" xmlns:prot="eml://ecoinformatics.org/protocol-2.1.1" xmlns:rp="eml://ecoinformatics.org/party-2.1.1" xmlns:sp="eml://ecoinformatics.org/storedProcedure-2.1.1" xmlns:spref="eml://ecoinformatics.org/spatialReference-2.1.1" xmlns:sr="eml://ecoinformatics.org/spatialRaster-2.1.1" xmlns:sv="eml://ecoinforma[...]
{'fraction_non_alphanumeric': 0.17879274730319028, 'fraction_numerical': 0.04544411292173514, 'mean_word_length': 4.953551912568306, 'pattern_counts': {'":': 24, '<': 45, '<?xml version=': 2, '>': 43, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '85870', 'license': 'Apache-2.0', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1706, 'n_words': 216, 'path': 'python_examples/08_search_retrieve.ipynb', 'repo_name': 'DataONEorg/dataone_examples', 'size': '4357'}