summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-18 12:26:36 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-18 12:26:36 -0800
commitce7cda4436c558f3a73b0b1b687d4dea3663bbfc (patch)
tree536107ee13a2f05e31c44d4b34cb58d7f59f8b20
parent0aae1c15ee6fd9f5173c3297d02b8aab912244d5 (diff)
downloadfatcat-ce7cda4436c558f3a73b0b1b687d4dea3663bbfc.tar.gz
fatcat-ce7cda4436c558f3a73b0b1b687d4dea3663bbfc.zip
state in elasticsearch (and deleted/redirects)
-rw-r--r--extra/elasticsearch/release_schema.json1
-rw-r--r--python/fatcat_tools/transforms.py10
2 files changed, 9 insertions, 2 deletions
diff --git a/extra/elasticsearch/release_schema.json b/extra/elasticsearch/release_schema.json
index c9b77301..9a712ad6 100644
--- a/extra/elasticsearch/release_schema.json
+++ b/extra/elasticsearch/release_schema.json
@@ -28,6 +28,7 @@
"release": {
"properties": {
"ident": { "type": "keyword" },
+ "state": { "type": "keyword" },
"revision": { "type": "keyword" },
"title": { "type": "text", "index": true, "analyzer": "textIcu", "search_analyzer":"textIcuSearch" },
"author": { "type": "alias", "path": "contrib_names" },
diff --git a/python/fatcat_tools/transforms.py b/python/fatcat_tools/transforms.py
index 0f957f9a..18bf7446 100644
--- a/python/fatcat_tools/transforms.py
+++ b/python/fatcat_tools/transforms.py
@@ -26,12 +26,18 @@ def release_to_elasticsearch(release):
Raises exception on error (never returns None)
"""
- if release.state != 'active':
- raise ValueError("Entity is not 'active'")
+ if release.state in ('redirect', 'deleted'):
+ return dict(
+ ident = release.ident,
+ state = release.state,
+ )
+ elif release.state != 'active'
+ raise ValueError("Unhandled release state: {}".format(release.state))
# First, the easy ones (direct copy)
t = dict(
ident = release.ident,
+ state = release.state,
revision = release.revision,
title = release.title,
release_type = release.release_type,