def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','user_mapping.py') userpillow = UserPillow(create_index=False) #current index #check current index aliased_indices = userpillow.check_alias() current_index = userpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER m['properties'] = dynamic.set_properties(self.doc_class) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) userpillow.default_mapping = m if hasattr(userpillow, '_calc_meta'): delattr(userpillow, '_calc_meta') output = [] output.append('USER_INDEX="%s_%s"' % (userpillow.es_index_prefix, userpillow.calc_meta())) output.append('USER_MAPPING=%s' % m) newcalc_index = "%s_%s" % (userpillow.es_index_prefix, userpillow.calc_meta()) print "Writing new user index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq', 'pillows', 'mappings', 'user_mapping.py') userpillow = UserPillow(create_index=False) #current index #check current index aliased_indices = userpillow.check_alias() current_index = userpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER user_special_types = { "domain": type_exact_match_string("domain", dual=True), "username": type_exact_match_string("username", dual=True), "user_data": { "dynamic": True, "type": "object" }, } user_special_types["username"]["fields"]["exact"][ "include_in_all"] = False user_special_types["username"]["fields"]["username"][ "analyzer"] = "simple" m['properties'] = dynamic.set_properties( self.doc_class, custom_types=user_special_types) m['_meta'][ 'comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) m['_all'] = {"analyzer": "simple"} userpillow.default_mapping = m if hasattr(userpillow, '_calc_meta'): delattr(userpillow, '_calc_meta') output = [] output.append('USER_INDEX="%s_%s"' % (userpillow.es_index_prefix, userpillow.calc_meta())) output.append('USER_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (userpillow.es_index_prefix, userpillow.calc_meta()) print "Writing new user index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write( "\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','user_mapping.py') userpillow = UserPillow(create_index=False) #current index #check current index aliased_indices = userpillow.check_alias() current_index = userpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER user_special_types = { "domain": type_exact_match_string("domain", dual=True), "username": type_exact_match_string("username", dual=True), "user_data": {"dynamic": True, "type": "object"}, } user_special_types["username"]["fields"]["exact"]["include_in_all"] = False user_special_types["username"]["fields"]["username"]["analyzer"] = "simple" m['properties'] = dynamic.set_properties(self.doc_class, custom_types=user_special_types) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) m['_all'] = {"analyzer": "simple"} userpillow.default_mapping = m if hasattr(userpillow, '_calc_meta'): delattr(userpillow, '_calc_meta') output = [] output.append('USER_INDEX="%s_%s"' % (userpillow.es_index_prefix, userpillow.calc_meta())) output.append('USER_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (userpillow.es_index_prefix, userpillow.calc_meta()) print "Writing new user index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)