diff --git a/couchdb-design/geo.js b/couchdb-design/geo.js index bd865b1..475d1ae 100644 --- a/couchdb-design/geo.js +++ b/couchdb-design/geo.js @@ -1,5 +1,11 @@ -function (doc) { - if (doc.geometry && doc.geometry.coordinates) { - st_index(doc.geometry); +{ + "_id": "_design/geo", + "_rev": "4-9f029d0a73284c772a8af9992891c14a", + "views": {}, + "language": "javascript", + "st_indexes": { + "newGeoIndex": { + "index": "function (doc) {\n if (doc.geometry && doc.geometry.coordinates) {\n st_index(doc.geometry);\n }\n}" + } } } \ No newline at end of file diff --git a/couchdb-design/graph.js b/couchdb-design/graph.js new file mode 100644 index 0000000..8a7cc14 --- /dev/null +++ b/couchdb-design/graph.js @@ -0,0 +1,10 @@ +{ + "_id": "_design/graph", + "_rev": "1-cb906dd3f7976ad13e7d54456c8a3c66", + "views": { + "triples": { + "map": "// get an identifier for this document\nfunction get_identifier(doc) {\n var identifier = '';\n var i = '';\n\n if (doc.document) {\n \n if (identifier === '') {\n // highwire\n if (doc.document.highwire) {\n for (i in doc.document.highwire) {\n switch (i) {\n case 'doi':\n identifier = doc.document.highwire[i][0];\n break;\n case 'pmid':\n if (identifier === '') {\n identifier = doc.document.highwire[i][0];\n }\n break;\n default:\n break;\n }\n }\n }\n }\n\n if (identifier === '') {\n // Dublin Core\n if (doc.document.dc) {\n for (i in doc.document.dc) {\n switch (i) {\n case 'Identifier':\n identifier = doc.document.dc[i][0];\n break;\n default:\n break;\n }\n }\n }\n }\n\n\n if (identifier === '') {\n // URI\n if (doc.uri) {\n identifier = doc.uri;\n }\n }\n \n\n }\n\n return identifier;\n} \n\n\nfunction(doc) {\n var identifier = get_identifier(doc);\n if (identifier !== '') {\n // triple \n if (doc.text) {\n if (doc.text !== '') {\n\n if (doc.tags) {\n for (var i in doc.tags) {\n\n var triple = [];\n triple.push(identifier);\n triple.push(doc.tags[i]);\n triple.push(doc.text);\n\n emit(doc._id, triple);\n }\n } \n }\n }\n }\n}" + } + }, + "language": "javascript" +} \ No newline at end of file diff --git a/couchdb-design/highwire.js b/couchdb-design/highwire.js new file mode 100644 index 0000000..6b92e7e --- /dev/null +++ b/couchdb-design/highwire.js @@ -0,0 +1,13 @@ +{ + "_id": "_design/highwire", + "_rev": "4-2fd52740c3cb086eefaf85437e31988e", + "views": { + "reference": { + "map": "function(doc) {\n\nif (doc.document.highwire) {\n if (doc.document.highwire.reference) {\n for (var i in doc.document.highwire.reference) {\n var s = doc.document.highwire.reference[i];\n s = s.replace(/\\n\\s+/, '');\n var parts = s.split(/;\\s*citation_/);\n \n var citation = {};\n \n for (var j in parts) {\n var kv = parts[j].split('=');\n var key = kv[0];\n key = key.replace(/citation_/, '');\n\n // customise the key(s) to match whatever data model for references we are using...\n switch (key) {\n case 'doi':\n key = 'DOI';\n break;\n case 'journal_title':\n key = 'container_title';\n break;\n case 'pages':\n key = 'page';\n break;\n default:\n break;\n }\n\n var value = kv[1];\n if (!citation[key]) {\n citation[key] = [];\n }\n citation[key].push(value);\n }\n \n emit(doc._id, citation);\n \n \n }\n }\n}\n\n}" + }, + "reference_doi": { + "map": "// get an identifier for this document\nfunction get_identifier(doc) {\n var identifier = '';\n var i = '';\n\n if (doc.document) {\n \n if (identifier === '') {\n // highwire\n if (doc.document.highwire) {\n for (i in doc.document.highwire) {\n switch (i) {\n case 'doi':\n identifier = doc.document.highwire[i][0];\n break;\n case 'pmid':\n if (identifier === '') {\n identifier = doc.document.highwire[i][0];\n }\n break;\n default:\n break;\n }\n }\n }\n }\n\n if (identifier === '') {\n // Dublin Core\n if (doc.document.dc) {\n for (i in doc.document.dc) {\n switch (i) {\n case 'Identifier':\n identifier = doc.document.dc[i][0];\n break;\n default:\n break;\n }\n }\n }\n }\n\n\n if (identifier === '') {\n // URI\n if (doc.uri) {\n identifier = doc.uri;\n }\n }\n \n\n }\n\n return identifier;\n} \n\nfunction(doc) {\n var identifier = get_identifier(doc);\n if (identifier !== '') {\nif (doc.document.highwire) {\n if (doc.document.highwire.reference) {\n for (var i in doc.document.highwire.reference) {\n var s = doc.document.highwire.reference[i];\n s = s.replace(/\\n\\s+/, '');\n var parts = s.split(/;\\s*citation_/);\n \n var citation = {};\n \n for (var j in parts) {\n var kv = parts[j].split('=');\n var key = kv[0];\n key = key.replace(/citation_/, '');\n\n // customise the key(s) to match whatever data model for references we are using...\n switch (key) {\n case 'doi':\n key = 'DOI';\n break;\n case 'journal_title':\n key = 'container_title';\n break;\n case 'pages':\n key = 'page';\n break;\n default:\n break;\n }\n\n var value = kv[1];\n if (!citation[key]) {\n citation[key] = [];\n }\n citation[key].push(value);\n }\n if (citation.DOI) {\n emit(identifier, citation.DOI);\n }\n \n }\n }\n}\n\n}\n}" + } + }, + "language": "javascript" +} \ No newline at end of file diff --git a/couchdb-design/tags.js b/couchdb-design/tags.js new file mode 100644 index 0000000..b83a3fe --- /dev/null +++ b/couchdb-design/tags.js @@ -0,0 +1,19 @@ +{ + "_id": "_design/tags", + "_rev": "6-db99d6c20eb1e2ae346d760dfff49fc7", + "views": { + "all": { + "map": "function get_text(doc) {\n var text = '';\n\n if (doc.text) {\n text = doc.text;\n } else {\n for (var i in doc.target[0].selector) {\n if (doc.target[0].selector[i].type == 'TextQuoteSelector') {\n text = doc.target[0].selector[i].exact;\n }\n }\n }\n \n\n return text;\n\n}\n\n\nfunction(doc) {\n if (doc.tags) {\n for (var i in doc.tags) {\n emit (doc.tags[i], get_text(doc));\n }\n } \n}" + }, + "identifier": { + "map": "// get an identifier for this document\nfunction get_identifier(doc) {\n var identifier = '';\n var i = '';\n\n if (doc.document) {\n \n if (identifier === '') {\n // highwire\n if (doc.document.highwire) {\n for (i in doc.document.highwire) {\n switch (i) {\n case 'doi':\n identifier = doc.document.highwire[i][0];\n break;\n case 'pmid':\n if (identifier === '') {\n identifier = doc.document.highwire[i][0];\n }\n break;\n default:\n break;\n }\n }\n }\n }\n\n if (identifier === '') {\n // Dublin Core\n if (doc.document.dc) {\n for (i in doc.document.dc) {\n switch (i) {\n case 'Identifier':\n identifier = doc.document.dc[i][0];\n break;\n default:\n break;\n }\n }\n }\n }\n\n\n if (identifier === '') {\n // URI\n if (doc.uri) {\n identifier = doc.uri;\n }\n }\n \n\n }\n\n return identifier;\n} \n\n\nfunction(doc) {\n var identifier = get_identifier(doc);\n if (identifier !== '') {\n emit(doc._id, identifier );\n }\n}" + }, + "geo": { + "map": "function get_text(doc) {\n var text = '';\n\n if (doc.text) {\n text = doc.text;\n } else {\n for (var i in doc.target[0].selector) {\n if (doc.target[0].selector[i].type == 'TextQuoteSelector') {\n text = doc.target[0].selector[i].exact;\n }\n }\n }\n \n\n return text;\n\n}\n\n\nfunction(doc) {\n if (doc.tags) {\n if (doc.tags.indexOf('geo') !== -1) {\n emit (doc._id, get_text(doc));\n }\n } \n}" + }, + "geo-bad": { + "map": "function get_text(doc) {\n var text = '';\n\n if (doc.text) {\n text = doc.text;\n } else {\n for (var i in doc.target[0].selector) {\n if (doc.target[0].selector[i].type == 'TextQuoteSelector') {\n text = doc.target[0].selector[i].exact;\n }\n }\n }\n \n\n return text;\n\n}\n\n\nfunction(doc) {\n if (doc.tags) {\n if (doc.tags.indexOf('geo') !== -1) {\n if (!doc.geometry) {\n emit (doc._id, get_text(doc));\n }\n }\n } \n}" + } + }, + "language": "javascript" +} \ No newline at end of file