class SearchSet(DjangoSearchSet): field1 = DjangoCharField(sources=["source1"]) field2 = DjangoCharField(sources=["source2"]) @classmethod def _get_raw_mapping(cls): return dict(source1=FieldType.INTEGER, source2=FieldType.FLOAT) class Meta: model = EmptyDjangoModel fields_to_exclude_from_suggestions = ["source1"]
class UnicornSearchSet(DjangoSearchSet): char_field = DjangoCharField() integer_field = DjangoIntegerField() float_field = DjangoFloatField() boolean_field = DjangoBooleanField() field_with_source = DjangoCharField(sources=["ok_it_is_a_source"]) field_with_several_sources = DjangoCharField(sources=["source1", "source2"]) @classmethod def get_raw_mapping(cls): return dict() class Meta: model = DjangoModel
class UnicornSearchSet(DjangoSearchSet): char_field = DjangoCharField() integer_field = DjangoIntegerField() float_field = DjangoFloatField() boolean_field = DjangoBooleanField() field_with_source = DjangoCharField(sources=["ok_it_is_a_source"]) field_with_several_sources = DjangoCharField( sources=["source1", "source2"]) @property def raw_mapping(self): return dict(source1=DjangoCharField(), source2=DjangoCharField(), ok_it_is_a_source=DjangoCharField()) class Meta: model = ElasticModel
class MySearchSet(DjangoSearchSet): a = DjangoCharField() @classmethod def get_raw_mapping(cls): return dict() class Meta: model = DjangoModel
class NotExcludingFieldsSearchSet(DjangoSearchSet): a = DjangoCharField() b = DjangoFloatField(sources=["c"]) @classmethod def _get_raw_mapping(cls): return dict(c=DjangoCharField()) class Meta: model = None
class SearchSet(DjangoSearchSet): char_field = DjangoCharField() integer_field = DjangoIntegerField(sources=["d", "tralala"]) @classmethod def _get_raw_mapping(cls): return {"x": None, "y": FieldType.BOOLEAN} class Meta: model = ElasticModel
class MySearchSet(DjangoSearchSet): a = DjangoCharField() @classmethod def get_raw_mapping(cls): return dict() class Meta: model = DjangoModel fields_to_exclude_from_suggestions = ["a"]
class ExcludeFieldsInClassSearchSet(DjangoSearchSet): a = DjangoCharField() b = DjangoFloatField(sources=["c"]) @classmethod def _get_raw_mapping(cls): return dict(c=DjangoFloatField()) class Meta: model = None fields_to_exclude_from_mapping = ["b"]
class ExcludeSourcesInFieldsSearchSet(DjangoSearchSet): a = DjangoCharField() b = DjangoFloatField(sources=["c"], exclude_sources_from_mapping=True) @classmethod def _get_raw_mapping(cls): return dict(c=DjangoFloatField()) class Meta: model = None
class MySearchSet(DjangoSearchSet): a = DjangoCharField( get_available_values_method=expected_available_values) b = DjangoBooleanField() @classmethod def get_raw_mapping(cls): return {k: None for k in ["c", "d"]} class Meta: model = DjangoModel
class MySearchSet(DjangoSearchSet): a = DjangoCharField(get_available_values_method=lambda *args: not_escaped_available_a_values) @classmethod def get_raw_mapping(cls): return dict() class Meta: model = DjangoModel escape_quotes_in_suggestions = False
class SearchSet(DjangoSearchSet): char_field = DjangoCharField() integer_field = DjangoIntegerField( sources=["d", "tralala"], exclude_sources_from_mapping=False) float_field = DjangoFloatField(sources=["c", "ululu"], exclude_sources_from_mapping=True) @classmethod def get_raw_mapping(cls): return dict() class Meta: model = ElasticModel fields_to_exclude_from_mapping = ["a", "b"]
class SearchSet(DjangoSearchSet): char_field = DjangoCharField() integer_field = DjangoIntegerField( sources=["d", "tralala"], exclude_sources_from_mapping=False) float_field = DjangoFloatField(sources=["c", "ululu"], exclude_sources_from_mapping=True, show_suggestions=False) @classmethod def _get_raw_mapping(cls): return {"x": None, "y": FieldType.BOOLEAN} class Meta: model = ElasticModel fields_to_exclude_from_mapping = ["x"] fields_to_exclude_from_suggestions = ["a", "b"]
class SearchSetMixin(metaclass=BaseSearchSetMetaClass): mixinfield = DjangoCharField()
class MyNewSearchSet(MySearchSet): a = DjangoCharField(show_suggestions=False) class Meta: model = EmptyDjangoModel
class SearchSet(SearchSetMixin, DjangoSearchSet): searchsetfield = DjangoCharField() class Meta: model = EmptyDjangoModel
def raw_mapping(self): return dict(source1=DjangoCharField(), source2=DjangoCharField(), ok_it_is_a_source=DjangoCharField())
def _get_raw_mapping(cls): return dict(c=DjangoCharField())