Create a new Solr schema for Yokozuna.

        :param schema: name of Solr schema
        :type schema: string
        :param content: actual defintion of schema (XML)
        :type content: string

        :rtype boolean
7741
def create_search_schema(self, schema, content):
        
        if not self.yz_wm_schema:
            raise NotImplementedError("Search 2.0 administration is not "
                                      "supported for this version")

        url = self.search_schema_path(schema)
        headers = {'Content-Type': 'application/xml'}

        # Run the request...
        status, header, body = self._request('PUT', url, headers, content)

        if status != 204:
            raise RiakError('Error creating Search 2.0 schema.')
        return True
437550
def _load_schema(self, location, xml=None):
        
        cachedir = self._cachedir
        # wsdl2py: deal with XML Schema
        if not os.path.isdir(cachedir): os.mkdir(cachedir)
    
        file = os.path.join(cachedir, '.cache')
        section = 'TYPES'
        cp = ConfigParser()
        try:
            cp.readfp(open(file, 'r'))
        except IOError:
            del cp;  cp = None
            
        option = location.replace(':', '-') # colons seem to screw up option
        if (cp is not None and cp.has_section(section) and 
            cp.has_option(section, option)):
            types = cp.get(section, option)
        else:
            # dont do anything to anames
            if not self._pyclass:
                containers.ContainerBase.func_aname = lambda instnc,n: str(n)
                
            from pyremotevbox.ZSI.wstools import XMLSchema
            reader = XMLSchema.SchemaReader(base_url=location)
            if xml is not None and isinstance(xml, basestring):
                schema = reader.loadFromString(xml)
            elif xml is not None:
                raise RuntimeError, 'Unsupported: XML must be string'
            elif not os.path.isfile(location):
                schema = reader.loadFromURL(location)
            else:
                schema = reader.reader.loadFromFile(location)
                
            # TODO: change this to keyword list
            class options:
                output_dir = cachedir
                schema = True
                simple_naming = False
                address = False
                lazy = self._lazy
                complexType = self._pyclass

            schema.location = location
            files = commands._wsdl2py(options, schema)
            if cp is None: cp = ConfigParser()
            if not cp.has_section(section): cp.add_section(section)
            types = filter(lambda f: f.endswith('_types.py'), files)[0]
            cp.set(section, option, types)
            cp.write(open(file, 'w'))
            
        if os.path.abspath(cachedir) not in sys.path:
            sys.path.append(os.path.abspath(cachedir))
            
        mod = os.path.split(types)[-1].rstrip('.py')
        return __import__(mod)
857029
def create_schema(self, connection):
        
        if '.' not in self.table:
            return

        query = 'CREATE SCHEMA IF NOT EXISTS {schema_name};'.format(schema_name=self.table.split('.')[0])
        connection.cursor().execute(query)
1163914
def schema(self):
        
        schema = "%s %s %s %s('%s'" % (
            self.name,
            self.data_type,
            self.index_type,
            self.key_type,
            self.index_name,
        )
        if self.includes is not None:
            schema += ", ["
            schema += ", ".join(("'%s'" % i for i in self.includes))
            schema += "]"
        return schema + ")"
145943
def create_db_schema(cls, cur, schema_name):
        
        create_schema_script = "CREATE SCHEMA {0} ;\n".format(schema_name)
        cur.execute(create_schema_script)
824277
def newDocTextLen(self, content, len):
        
        ret = libxml2mod.xmlNewDocTextLen(self._o, content, len)
        if ret is None:raise treeError('xmlNewDocTextLen() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
617661
def build_schema(schema: Schema) -> Mapping[str, Any]:
    
    builder = Schemas(build_parameter=build_parameter)
    return builder.build(schema)
515531
function Schema (sc, size) {
  if (!(this instanceof Schema)) return new Schema(sc);
  debug('======BUILDING PHASE======');
  helpers.validate(sc);
  debug('schema size=%d being built', size);
  this._schema = this;
  this._document = helpers.build(sc, '$root', this);
  this._state = { // serve as global state
    index: -1,
    size: size,
    counter: []
  };
  debug('======BUILDING ENDS======');
}
700267
private static Schema schema(SearchKeyType keyType) {
		Schema sch = new Schema();
		for (int i = 0; i < keyType.length(); i++)
			sch.addField(keyFieldName(i), keyType.get(i));
		sch.addField(SCHEMA_RID_BLOCK, BIGINT);
		sch.addField(SCHEMA_RID_ID, INTEGER);
		return sch;
	}
404042
def schema():
        """"""
        return Schema({
            'script': And(Or(type(' '), type(u' ')), len),
            Optional('title', default=''): str,
            Optional('model', default={}): {Optional(And(str, len)): object},
            Optional('env', default={}): {Optional(And(str, len)): And(str, len)},
            Optional('item', default=None): object,
            Optional('dry_run', default=False): bool,
            Optional('debug', default=False): bool,
            Optional('strict', default=False): bool,
            Optional('variables', default={}): {
                Optional(And(Or(type(' '), type(u' ')), len, Regex(r'([a-zA-Z][_a-zA-Z]*)'))):
                    Or(type(' '), type(u' '))
            },
            Optional('temporary_scripts_path', default=''): Or(type(''), type(u'')),
            Optional('internal', default=False): bool
        })
1295954
def get_search_schema(self, schema):
        
        if not self.yz_wm_schema:
            raise NotImplementedError("Search 2.0 administration is not "
                                      "supported for this version")
        url = self.search_schema_path(schema)

        # Run the request...
        status, _, body = self._request('GET', url)

        if status == 200:
            result = {}
            result['name'] = schema
            result['content'] = bytes_to_str(body)
            return result
        else:
            raise RiakError('Error getting Search 2.0 schema.')
1056544
def create(cls, schema, name):
        
        fn = cls.tags.get(name, XBuiltin)
        return fn(schema, name)
422633
def make_schema(fields, datefields=()):
    '''
    
    '''
    text_field = whoosh.fields.TEXT(analyzer=whoosh.analysis.SimpleAnalyzer())
    fields = dict.fromkeys(fields, text_field)
    if datefields:
        datefields = dict.fromkeys(datefields, whoosh.fields.DATETIME)
        fields.update(datefields)
    schema = whoosh.fields.Schema()
    for fieldname in fields:
        schema.add(fieldname, fields[fieldname])
    return schema
863725
def _compile_schema(self, schema):
        
        assert self.matcher == schema.matcher

        self.name = schema.name
        self.compiled_type = schema.compiled_type

        return schema.compiled
1347521
def build_schema(self, fields, language):
        
        content_field_name = ''
        mapping = {
            DJANGO_CT: {'type': 'string', 'index': 'not_analyzed', 'include_in_all': False},
            DJANGO_ID: {'type': 'string', 'index': 'not_analyzed', 'include_in_all': False},
        }

        for field_name, field_class in fields.items():
            field_mapping = FIELD_MAPPINGS.get(
                field_class.field_type, DEFAULT_FIELD_MAPPING).copy()
            if field_class.boost != 1.0:
                field_mapping['boost'] = field_class.boost

            if field_class.document is True:
                content_field_name = field_class.index_fieldname

            # Do this last to override `text` fields.
            if field_mapping['type'] == 'string':
                # Use the language analyzer for text fields.
                if field_mapping['analyzer'] == DEFAULT_FIELD_MAPPING['analyzer']:
                    field_mapping['analyzer'] = get_analyzer_for(language)
                if field_class.indexed is False or hasattr(field_class, 'facet_for'):
                    field_mapping['index'] = 'not_analyzed'
                    del field_mapping['analyzer']

            mapping[field_class.index_fieldname] = field_mapping

        return content_field_name, mapping
113759
def update_schema(self, catalog="hypermap"):
        
        schema_url = "{0}/solr/{1}/schema".format(SEARCH_URL, catalog)
        print schema_url

        # create a special type to draw better heatmaps.
        location_rpt_quad_5m_payload = {
            "add-field-type": {
                "name": "location_rpt_quad_5m",
                "class": "solr.SpatialRecursivePrefixTreeFieldType",
                "geo": False,
                "worldBounds": "ENVELOPE(-180, 180, 180, -180)",
                "prefixTree": "packedQuad",
                "distErrPct": "0.025",
                "maxDistErr": "0.001",
                "distanceUnits": "degrees"
            }
        }
        requests.post(schema_url, json=location_rpt_quad_5m_payload)

        # create a special type to implement ngrm text for search.
        text_ngrm_payload = {
            "add-field-type": {
                "name": "text_ngrm",
                "class": "solr.TextField",
                "positionIncrementGap": "100",
                "indexAnalyzer": {
                    "tokenizer": {
                        "class": "solr.WhitespaceTokenizerFactory"
                    },
                    "filters": [
                        {
                            "class": "solr.NGramFilterFactory",
                            "minGramSize": "1",
                            "maxGramSize": "50"
                        }, {
                            "class": "solr.LowerCaseFilterFactory"
                        }
                    ]
                },
                "queryAnalyzer": {
                    "tokenizer": {
                        "class": "solr.WhitespaceTokenizerFactory"
                    },
                    "filters": [
                        {
                            "class": "solr.LowerCaseFilterFactory",
                        }
                    ]
                }
            }
        }
        requests.post(schema_url, json=text_ngrm_payload)

        # now the other fields
        fields = [
            {"name": "abstract", "type": "string"},
            {"name": "abstract_txt", "type": "text_ngrm"},
            {"name": "area", "type": "pdouble"},
            {"name": "availability", "type": "string"},
            {"name": "bbox", "type": "location_rpt_quad_5m"},
            {"name": "domain_name", "type": "string"},
            {"name": "is_public", "type": "boolean"},
            {"name": "is_valid", "type": "boolean"},
            {"name": "keywords", "type": "string", "multiValued": True},
            {"name": "last_status", "type": "boolean"},
            {"name": "layer_category", "type": "string"},
            {"name": "layer_date", "type": "pdate", "docValues": True},
            {"name": "layer_datetype", "type": "string"},
            {"name": "layer_id", "type": "plong"},
            {"name": "layer_originator", "type": "string"},
            {"name": "layer_originator_txt", "type": "text_ngrm"},
            {"name": "layer_username", "type": "string"},
            {"name": "layer_username_txt", "type": "text_ngrm"},
            {"name": "location", "type": "string"},
            {"name": "max_x", "type": "pdouble"},
            {"name": "max_y", "type": "pdouble"},
            {"name": "min_x", "type": "pdouble"},
            {"name": "min_y", "type": "pdouble"},
            {"name": "name", "type": "string"},
            {"name": "recent_reliability", "type": "pdouble"},
            {"name": "reliability", "type": "pdouble"},
            {"name": "service_id", "type": "plong"},
            {"name": "service_type", "type": "string"},
            {"name": "srs", "type": "string", "multiValued": True},
            {"name": "tile_url", "type": "string"},
            {"name": "title", "type": "string"},
            {"name": "title_txt", "type": "text_ngrm"},
            {"name": "type", "type": "string"},
            {"name": "url", "type": "string"},
            {"name": "uuid", "type": "string", "required": True},
            {"name": "centroid_y", "type": "pdouble"},
            {"name": "centroid_x", "type": "pdouble"},
        ]

        copy_fields = [
            {"source": "*", "dest": "_text_"},
            {"source": "title", "dest": "title_txt"},
            {"source": "abstract", "dest": "abstract_txt"},
            {"source": "layer_originator", "dest": "layer_originator_txt"},
            {"source": "layer_username", "dest": "layer_username_txt"},
        ]

        headers = {
            "Content-type": "application/json"
        }

        for field in fields:
            data = {
                "add-field": field
            }
            requests.post(schema_url, json=data, headers=headers)

        for field in copy_fields:
            data = {
                "add-copy-field": field
            }
            print data
            requests.post(schema_url, json=data, headers=headers)
464236
def create_schema(self, check_if_exists=False, sync_schema=True,
                      verbosity=1):
        

        # safety check
        _check_schema_name(self.schema_name)
        cursor = connection.cursor()

        if check_if_exists and schema_exists(self.schema_name):
            return False

        # create the schema
        cursor.execute('CREATE SCHEMA %s' % self.schema_name)

        if sync_schema:
            call_command('migrate_schemas',
                         schema_name=self.schema_name,
                         interactive=False,
                         verbosity=verbosity)

        connection.set_schema_to_public()