Python elasticsearch_dsl.String() Examples
The following are 3
code examples of elasticsearch_dsl.String().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
elasticsearch_dsl
, or try the search function
.
Example #1
Source File: mapping.py From django-seeker with BSD 2-Clause "Simplified" License | 6 votes |
def document_field(field): """ The default ``field_factory`` method for converting Django field instances to ``elasticsearch_dsl.Field`` instances. Auto-created fields (primary keys, for example) and one-to-many fields (reverse FK relationships) are skipped. """ if field.auto_created or field.one_to_many: return None if field.many_to_many: return RawMultiString defaults = { models.DateField: dsl.Date(), models.DateTimeField: dsl.Date(), models.IntegerField: dsl.Long(), models.PositiveIntegerField: dsl.Long(), models.BooleanField: dsl.Boolean(), models.NullBooleanField: dsl.Boolean(), models.SlugField: dsl.String(index='not_analyzed'), models.DecimalField: dsl.Double(), models.FloatField: dsl.Float(), } return defaults.get(field.__class__, RawString)
Example #2
Source File: views.py From django-seeker with BSD 2-Clause "Simplified" License | 6 votes |
def get_field_sort(self, field_name): """ Given a field name, returns the field name that should be used for sorting. If a mapping defines a .raw sub-field, that is used, otherwise the field name itself is used if index=not_analyzed. """ if field_name.endswith('.raw'): return field_name if field_name in self.sort_fields: return self.sort_fields[field_name] if field_name in self.document._doc_type.mapping: dsl_field = self.document._doc_type.mapping[field_name] if isinstance(dsl_field, (dsl.Object, dsl.Nested)): return None if not isinstance(dsl_field, dsl.String): return field_name if 'raw' in dsl_field.fields: return '%s.raw' % field_name elif getattr(dsl_field, 'index', None) == 'not_analyzed': return field_name return None
Example #3
Source File: reindex_tokens.py From bearded-avenger with Mozilla Public License 2.0 | 6 votes |
def restore_tokens(): connections.create_connection(hosts=ES_NODES) Index(INDEX_NAME).delete() class Token(DocType): username = String() token = String() expires = Date() read = Boolean() write = Boolean() revoked = Boolean() acl = String() groups = String() admin = Boolean() last_activity_at = Date() class Meta: index = INDEX_NAME Token.init() reindex_results = connections.get_connection().reindex(body={"source": {"index": BACKUP_INDEX_NAME}, "dest": {"index": INDEX_NAME}}, request_timeout=3600) if reindex_results.get('created') + reindex_results.get('updated') == reindex_results.get('total'): return ('Tokens restored to previous schema successfully!') else: return ('Tokens did not restore from backup properly')