diff --git a/hive/indexer/cached_post.py b/hive/indexer/cached_post.py
index 53a6ad0..f731b41 100644
--- a/hive/indexer/cached_post.py
+++ b/hive/indexer/cached_post.py
@@ -470,17 +470,18 @@ class CachedPost:
     @classmethod
     def _tag_sqls(cls, pid, tags, diff=True):
         """Generate SQL "deltas" for a post_id's associated tags."""
+        next_tags = set(tags)
         curr_tags = set()
         if diff:
             sql = "SELECT tag FROM hive_post_tags WHERE post_id = :id"
             curr_tags = set(DB.query_col(sql, id=pid))
 
-        to_rem = (curr_tags - tags)
+        to_rem = (curr_tags - next_tags)
         if to_rem:
             sql = "DELETE FROM hive_post_tags WHERE post_id = :id AND tag IN :tags"
             yield (sql, dict(id=pid, tags=tuple(to_rem)))
 
-        to_add = (tags - curr_tags)
+        to_add = (next_tags - curr_tags)
         if to_add:
             params = _keyify(to_add)
             vals = ["(:id, :%s)" % key for key in params.keys()]
diff --git a/hive/utils/post.py b/hive/utils/post.py
index 562b518..87e5dfe 100644
--- a/hive/utils/post.py
+++ b/hive/utils/post.py
@@ -3,7 +3,7 @@
 
 import math
 import ujson as json
-from funcy.seqs import first
+from funcy.seqs import first, distinct
 
 from hive.utils.normalize import sbd_amount, rep_log10, safe_img_url, parse_time, utc_timestamp
 
@@ -33,8 +33,9 @@ def post_basic(post):
     tags = [post['category']]
     if md and 'tags' in md and isinstance(md['tags'], list):
         tags = tags + md['tags']
-    tags = set(list(map(lambda tag: (str(tag) or '').strip('# ').lower()[:32], tags))[0:5])
-    tags.discard('')
+    tags = map(lambda tag: (str(tag) or '').strip('# ').lower()[:32], tags)
+    tags = filter(None, tags)
+    tags = list(distinct(tags))[:5]
     is_nsfw = 'nsfw' in tags
 
     body = post['body']

only first 4 tags are indexed
The symptoms described in this post have been confirmed; PR incoming.

https://steemit.com/steemit/@free-reign/5th-tag-doesn-t-seem-to-be-getting-posts-like-the-other-4-anymore
diff --git a/tests/utils/test_utils_post.py b/tests/utils/test_utils_post.py
index 58332e9..8c61014 100644
--- a/tests/utils/test_utils_post.py
+++ b/tests/utils/test_utils_post.py
@@ -89,11 +89,59 @@ POST_1 = {
     "vote_rshares": 0
 }
 
+POST_2 = {
+    "abs_rshares": 0,
+    "active": "2017-06-20T15:53:51",
+    "active_votes": [],
+    "allow_curation_rewards": True,
+    "allow_replies": True,
+    "allow_votes": True,
+    "author": "test-safari",
+    "author_reputation": "468237543674",
+    "author_rewards": 23,
+    "beneficiaries": [],
+    "body": "https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg",
+    "body_length": 0,
+    "cashout_time": "1969-12-31T23:59:59",
+    "category": "steemit",
+    "children": 0,
+    "children_abs_rshares": 0,
+    "created": "2017-06-20T15:53:51",
+    "curator_payout_value": "0.000 SBD",
+    "depth": 0,
+    "id": 4437869,
+    "json_metadata": "{\"tags\":[\"steemit\",\"steem\",\"\",\"abc\",\"bcd\",\"cde\"]}",
+    "last_payout": "2017-06-27T15:53:51",
+    "last_update": "2017-06-20T15:53:51",
+    "max_accepted_payout": "1000000.000 SBD",
+    "max_cashout_time": "1969-12-31T23:59:59",
+    "net_rshares": 0,
+    "net_votes": 4,
+    "parent_author": "",
+    "parent_permlink": "spam",
+    "pending_payout_value": "0.000 SBD",
+    "percent_steem_dollars": 10000,
+    "permlink": "june-spam",
+    "promoted": "0.000 SBD",
+    "reblogged_by": [],
+    "replies": [],
+    "reward_weight": 10000,
+    "root_author": "test-safari",
+    "root_permlink": "june-spam",
+    "root_title": "June Spam",
+    "title": "June Spam",
+    "total_payout_value": "0.044 SBD",
+    "total_pending_payout_value": "0.000 STEEM",
+    "total_vote_weight": 0,
+    "url": "/spam/@test-safari/june-spam",
+    "vote_rshares": 0
+}
+
 def test_post_basic():
     ret = post_basic(POST_1)
     expect = {'json_metadata': {'tags': ['spam'], 'image': ['https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg', 'https://example.com/image.jpg'], 'app': 'steemit/0.1', 'format': 'markdown'},
               'image': 'https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg',
-              'tags': {'spam'},
+              'tags': ['spam'],
               'is_nsfw': False,
               'body': 'https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg',
               'preview': 'https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg',
@@ -103,6 +151,11 @@ def test_post_basic():
               'is_full_power': False}
     assert ret == expect
 
+def test_post_basic_tags():
+    tags = post_basic(POST_2)['tags']
+    expected = ['steemit', 'steem', 'abc', 'bcd', 'cde']
+    assert tags == expected, "got %s" % tags
+
 def test_post_legacy():
     ret = post_legacy(POST_1)
     expect = {'allow_curation_rewards': True,

pip install -e .[test]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aiocache==0.12.3
aiohttp==3.8.6
aiopg @ https://github.com/aio-libs/aiopg/tarball/862fff97e4ae465333451a4af2a838bfaa3dd0bc
aiosignal==1.2.0
apply-defaults==0.1.6
astroid==2.11.7
async-timeout==4.0.2
asynctest==0.13.0
attrs==22.2.0
backports.zoneinfo==0.2.1
certifi==2021.5.30
charset-normalizer==3.0.1
ConfigArgParse==1.7
coverage==6.2
dateparser==1.1.3
dill==0.3.4
execnet==1.9.0
frozenlist==1.2.0
funcsigs==1.0.2
funcy==2.0
future==1.0.0
git-pylint-commit-hook==2.6.1
greenlet==2.0.2
-e git+https://github.com/steemit/hivemind.git@a96b77f9a4cc0f07e2eb1376c9d5a61016f9bbc2#egg=hivemind
humanize==3.14.0
idna==3.10
idna-ssl==1.1.0
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
isort==5.10.1
jsonrpcserver==4.0.1
jsonschema==2.6.0
lazy-object-proxy==1.7.1
maya==0.6.1
mccabe==0.7.0
multidict==5.2.0
packaging==21.3
pdoc==0.4.1
pendulum==2.1.2
pep8==1.7.1
platformdirs==2.4.0
pluggy==1.0.0
psycopg2-binary==2.9.5
py==1.11.0
pylint==2.13.9
pyparsing==3.1.4
pytest==7.0.1
pytest-asyncio==0.16.0
pytest-console-scripts==1.3.1
pytest-cov==4.0.0
pytest-mock==3.6.1
pytest-pylint==0.18.0
pytest-xdist==3.0.2
python-dateutil==2.9.0.post0
pytz==2025.2
pytz-deprecation-shim==0.1.0.post0
pytzdata==2020.1
regex==2022.3.2
six==1.17.0
snaptime==0.2.4
SQLAlchemy==1.4.54
toml==0.10.2
tomli==1.2.3
toolz==0.12.0
typed-ast==1.5.5
typing_extensions==4.1.1
tzdata==2025.2
tzlocal==4.2
ujson==4.3.0
urllib3==1.26.20
wrapt==1.16.0
yapf==0.32.0
yarl==1.7.2
zipp==3.6.0

name: hivemind
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aiocache==0.12.3
      - aiohttp==3.8.6
      - aiopg==0.15.0
      - aiosignal==1.2.0
      - apply-defaults==0.1.6
      - astroid==2.11.7
      - async-timeout==4.0.2
      - asynctest==0.13.0
      - attrs==22.2.0
      - backports-zoneinfo==0.2.1
      - charset-normalizer==3.0.1
      - configargparse==1.7
      - coverage==6.2
      - dateparser==1.1.3
      - dill==0.3.4
      - execnet==1.9.0
      - frozenlist==1.2.0
      - funcsigs==1.0.2
      - funcy==2.0
      - future==1.0.0
      - git-pylint-commit-hook==2.6.1
      - greenlet==2.0.2
      - humanize==3.14.0
      - idna==3.10
      - idna-ssl==1.1.0
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - isort==5.10.1
      - jsonrpcserver==4.0.1
      - jsonschema==2.6.0
      - lazy-object-proxy==1.7.1
      - maya==0.6.1
      - mccabe==0.7.0
      - multidict==5.2.0
      - packaging==21.3
      - pdoc==0.4.1
      - pendulum==2.1.2
      - pep8==1.7.1
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - psycopg2-binary==2.9.5
      - py==1.11.0
      - pylint==2.13.9
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-asyncio==0.16.0
      - pytest-console-scripts==1.3.1
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - pytest-pylint==0.18.0
      - pytest-xdist==3.0.2
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pytz-deprecation-shim==0.1.0.post0
      - pytzdata==2020.1
      - regex==2022.3.2
      - six==1.17.0
      - snaptime==0.2.4
      - sqlalchemy==1.4.54
      - toml==0.10.2
      - tomli==1.2.3
      - toolz==0.12.0
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - tzdata==2025.2
      - tzlocal==4.2
      - ujson==4.3.0
      - urllib3==1.26.20
      - wrapt==1.16.0
      - yapf==0.32.0
      - yarl==1.7.2
      - zipp==3.6.0
prefix: /opt/conda/envs/hivemind

tests/utils/test_utils_post.py::test_post_basic tests/utils/test_utils_post.py::test_post_basic_tags
tests/utils/test_utils_post.py::test_post_legacy tests/utils/test_utils_post.py::test_post_payout tests/utils/test_utils_post.py::test_post_stats
hive/indexer/cached_post.py hive/utils/post.py
hive/indexer/cached_post.py hive/utils/post.py