فهرست منبع

HUE-7587 [search] Properly create collection with default field when specified

Romain Rigaux 8 سال پیش
والد
کامیت
a9d4031
2فایلهای تغییر یافته به همراه12 افزوده شده و 10 حذف شده
  1. 3 2
      desktop/libs/indexer/src/indexer/api3.py
  2. 9 8
      desktop/libs/indexer/src/indexer/solr_client.py

+ 3 - 2
desktop/libs/indexer/src/indexer/api3.py

@@ -210,8 +210,8 @@ def importer_submit(request):
 
 
 def _create_index(user, fs, client, source, destination, index_name):
-  unique_key_field = destination['indexerDefaultField'] and destination['indexerDefaultField'][0] or None
-  df = destination['indexerPrimaryKey'] and destination['indexerPrimaryKey'][0] or None
+  unique_key_field = destination['indexerPrimaryKey'] and destination['indexerPrimaryKey'][0] or None
+  df = destination['indexerDefaultField'] and destination['indexerDefaultField'][0] or None
   kwargs = {}
 
   if source['inputFormat'] not in ('manual', 'table'):
@@ -311,6 +311,7 @@ def _index(request, file_format, collection_name, query=None, start_time=None, l
       name=collection_name,
       fields=request.POST.get('fields', schema_fields),
       unique_key_field=unique_field
+      # No df currently
     )
 
   if file_format['inputFormat'] == 'table':

+ 9 - 8
desktop/libs/indexer/src/indexer/solr_client.py

@@ -115,14 +115,6 @@ class SolrClient(object):
           # Note: uniqueKey is always 'id'
           self.api.create_config(name, config_name, immutable=False)
 
-          if df:
-            self.api.update_config(name, {
-              'update-requesthandler': {
-                "name": "/query",
-                "df": df,
-              }
-            })
-
         self.api.create_collection2(name, config_name=name, shards=shards, replication=replication)
 
         fields = [{
@@ -132,6 +124,15 @@ class SolrClient(object):
           } for field in fields if field['name'] != 'id'
         ]
         self.api.add_fields(name, fields)
+
+        if df:
+          self.api.update_config(name, {
+            'update-requesthandler': {
+              "name": "/select",
+              "class": "solr.SearchHandler",
+              "defaults": {"df": df},
+            }
+          })
       else:
         self._create_cloud_config(name, fields, unique_key_field, df)
         self.api.create_collection2(name, config_name=config_name, shards=shards, replication=replication)