Преглед изворни кода

HUE-7385 [solr] Do not install Solr 7 examples with auto creation of fields

Todo, filter out ID field to not try to recreate it twice
Romain Rigaux пре 8 година
родитељ
комит
dabfc81

+ 4 - 0
desktop/libs/indexer/src/indexer/management/commands/indexer_setup.py

@@ -98,6 +98,10 @@ class Command(BaseCommand):
           unique_key_field=collection['uniqueKeyField'],
           df=collection['df']
       )
+
+      if self.client.is_solr_six_or_more():
+        self.client.update_config(collection['name'], {'set-user-property': {'update.autoCreateFields': 'false'}})
+
       with open(path) as fh:
         self.client.index(collection['name'], fh.read())
 

+ 5 - 0
desktop/libs/indexer/src/indexer/solr_client.py

@@ -100,6 +100,7 @@ class SolrClient(object):
         } for field in fields
       ]
       if self.is_solr_six_or_more():
+        self.api.update_config(name, {'set-user-property': {'update.autoCreateFields': 'false'}})
         self.api.add_fields(name, fields)
     else:
       self._create_non_solr_cloud_index(name, fields, unique_key_field, df)
@@ -164,6 +165,10 @@ class SolrClient(object):
     return self.api.delete_alias(name)
 
 
+  def update_config(self, name, properties):
+    return self.api.update_config(name, properties)
+
+
   def is_solr_cloud_mode(self):
     global _IS_SOLR_CLOUD
 

+ 12 - 0
desktop/libs/libsolr/src/libsolr/api.py

@@ -411,6 +411,18 @@ class SolrApi(object):
       raise PopupException(e, title=_('Error while accessing Solr'))
 
 
+  def update_config(self, name, properties):
+    try:
+      params = self._get_params() + (
+        ('wt', 'json'),
+      )
+
+      response = self._root.post('%(collection)s/config' % {'collection': name}, params=params, data=json.dumps(properties), contenttype='application/json')
+      return self._get_json(response)
+    except RestException, e:
+      raise PopupException(e, title=_('Error while accessing Solr'))
+
+
   def add_fields(self, name, fields):
     try:
       params = self._get_params() + (