class NotExcludingFieldsSearchSet(DjangoSearchSet): a = DjangoCharField() b = DjangoFloatField(sources=["c"]) @classmethod def _get_raw_mapping(cls): return dict(c=DjangoCharField()) class Meta: model = None
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 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 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 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 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 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"]
def _get_raw_mapping(cls): return dict(c=DjangoFloatField())