Repository: pypi/warehouse

Issue:
Search by topic broken ?
Browsing packages, then choosing the Internet / WWW9HTTP / Browser topics gives no result:

https://pypi.org/search/?q=&o=&c=Topic+%3A%3A+Internet+%3A%3A+WWW%2FHTTP+%3A%3A+Browsers

There should be at least the [mechanoid package](https://pypi.org/project/mechanoid/)

Using firefox 50.1:0 on Ubuntu 16.04


Discussion:
This does indeed seem to be a bug with filtering by any classifier, thanks for reporting it.

Resolving patch:
diff --git a/warehouse/cli/search/reindex.py b/warehouse/cli/search/reindex.py
--- a/warehouse/cli/search/reindex.py
+++ b/warehouse/cli/search/reindex.py
@@ -70,6 +70,7 @@ def reindex(config, **kwargs):
     random_token = binascii.hexlify(os.urandom(5)).decode("ascii")
     new_index_name = "{}-{}".format(index_base, random_token)
     doc_types = config.registry.get("search.doc_types", set())
+    shards = config.registry.get("elasticsearch.shards", 1)
 
     # Create the new index with zero replicas and index refreshes disabled
     # while we are bulk indexing.
@@ -77,10 +78,11 @@ def reindex(config, **kwargs):
         new_index_name,
         doc_types,
         using=client,
-        shards=config.registry.get("elasticsearch.shards", 1),
+        shards=shards,
         replicas=0,
         interval="-1",
     )
+    new_index.create(wait_for_active_shards=shards)
 
     # From this point on, if any error occurs, we want to be able to delete our
     # in progress index.


Test patch:
diff --git a/tests/unit/cli/search/test_reindex.py b/tests/unit/cli/search/test_reindex.py
--- a/tests/unit/cli/search/test_reindex.py
+++ b/tests/unit/cli/search/test_reindex.py
@@ -63,6 +63,7 @@ def __init__(self):
         self.put_settings = pretend.call_recorder(lambda *a, **kw: None)
         self.forcemerge = pretend.call_recorder(lambda *a, **kw: None)
         self.delete = pretend.call_recorder(lambda *a, **kw: None)
+        self.create = pretend.call_recorder(lambda *a, **kw: None)
 
     def exists_alias(self, name):
         return name in self.aliases
@@ -184,6 +185,7 @@ def project_docs(db):
             registry={
                 "elasticsearch.client": es_client,
                 "elasticsearch.index": "warehouse",
+                "elasticsearch.shards": 42,
                 "sqlalchemy.engine": db_engine,
             },
         )
@@ -201,9 +203,22 @@ def project_docs(db):
         assert sess_obj.execute.calls == [
             pretend.call("SET statement_timeout = '600s'"),
         ]
-        assert parallel_bulk .calls == [pretend.call(es_client, docs)]
+        assert parallel_bulk.calls == [pretend.call(es_client, docs)]
         assert sess_obj.rollback.calls == [pretend.call()]
         assert sess_obj.close.calls == [pretend.call()]
+        assert es_client.indices.create.calls == [
+            pretend.call(
+                body={
+                    'settings': {
+                        'number_of_shards': 42,
+                        'number_of_replicas': 0,
+                        'refresh_interval': '-1',
+                    }
+                },
+                wait_for_active_shards=42,
+                index='warehouse-cbcbcbcbcb',
+            )
+        ]
         assert es_client.indices.delete.calls == []
         assert es_client.indices.aliases == {
             "warehouse": ["warehouse-cbcbcbcbcb"],
@@ -252,6 +267,7 @@ def project_docs(db):
             registry={
                 "elasticsearch.client": es_client,
                 "elasticsearch.index": "warehouse",
+                "elasticsearch.shards": 42,
                 "sqlalchemy.engine": db_engine,
             },
         )
@@ -272,6 +288,19 @@ def project_docs(db):
         assert parallel_bulk.calls == [pretend.call(es_client, docs)]
         assert sess_obj.rollback.calls == [pretend.call()]
         assert sess_obj.close.calls == [pretend.call()]
+        assert es_client.indices.create.calls == [
+            pretend.call(
+                body={
+                    'settings': {
+                        'number_of_shards': 42,
+                        'number_of_replicas': 0,
+                        'refresh_interval': '-1',
+                    }
+                },
+                wait_for_active_shards=42,
+                index='warehouse-cbcbcbcbcb',
+            )
+        ]
         assert es_client.indices.delete.calls == [
             pretend.call('warehouse-aaaaaaaaaa'),
         ]