Example #1
0
 def __init__(self, *args, **kwargs):
     super(ContentField, self).__init__(*args, **kwargs)
     self.properties['slug'] = field.construct_field('string', not_analyzed=True)
     self.properties['feature_type'] = SlugObjectField(not_analyzed=True)
     self.properties['tags'] = field.construct_field({
         'type': 'nested',
         'properties': {
             'slug': {'type': 'string', 'index': 'not_analyzed'}
         }
     })
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        "string", fields={"raw": {"type": "string", "index": "not_analyzed"}, "eng": field.String(analyzer="english")}
    )

    assert isinstance(f, field.String)
    assert {
        "type": "string",
        "fields": {
            "raw": {"type": "string", "index": "not_analyzed"},
            "eng": {"type": "string", "analyzer": "english"},
        },
    } == f.to_dict()
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        'string',
        fields={
            'raw': {'type': 'string', 'index': 'not_analyzed'},
            'eng': field.String(analyzer='english'),
        }
    )

    assert isinstance(f, field.String)
    assert {
        'type': 'string',
        'fields': {
            'raw': { 'type': 'string', 'index': 'not_analyzed'},
            'eng': { 'type': 'string', 'analyzer': 'english'},
        }
    } == f.to_dict()
Example #4
0
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        'text',
        fields={
            'raw': {'type': 'keyword'},
            'eng': field.Text(analyzer='english'),
        }
    )

    assert isinstance(f, field.Text)
    assert {
        'type': 'text',
        'fields': {
            'raw': {'type': 'keyword'},
            'eng': {'type': 'text', 'analyzer': 'english'},
        }
    } == f.to_dict()
Example #5
0
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        'string',
        fields={
            'raw': {'type': 'string', 'index': 'not_analyzed'},
            'eng': field.String(analyzer='english'),
        }
    )

    assert isinstance(f, field.String)
    assert {
        'type': 'string',
        'fields': {
            'raw': { 'type': 'string', 'index': 'not_analyzed'},
            'eng': { 'type': 'string', 'analyzer': 'english'},
        }
    } == f.to_dict()
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        'text',
        fields={
            'raw': {'type': 'keyword'},
            'eng': field.Text(analyzer='english'),
        }
    )

    assert isinstance(f, field.Text)
    assert {
        'type': 'text',
        'fields': {
            'raw': {'type': 'keyword'},
            'eng': {'type': 'text', 'analyzer': 'english'},
        }
    } == f.to_dict()
Example #7
0
def test_multi_fields_are_accepted_and_parsed():
    f = field.construct_field(
        "text",
        fields={
            "raw": {
                "type": "keyword"
            },
            "eng": field.Text(analyzer="english")
        },
    )

    assert isinstance(f, field.Text)
    assert {
        "type": "text",
        "fields": {
            "raw": {
                "type": "keyword"
            },
            "eng": {
                "type": "text",
                "analyzer": "english"
            },
        },
    } == f.to_dict()
Example #8
0
def test_field_from_dict():
    f = field.construct_field({'type': 'text', 'index': 'not_analyzed'})

    assert isinstance(f, field.Text)
    assert {'type': 'text', 'index': 'not_analyzed'} == f.to_dict()
def test_field_from_dict():
    f = field.construct_field({'type': 'string', 'index': 'not_analyzed'})

    assert isinstance(f, field.String)
    assert {'type': 'string', 'index': 'not_analyzed'} == f.to_dict()
Example #10
0
 def __init__(self, *args, **kwargs):
     super(ColorField, self).__init__(*args, **kwargs)
     self.properties["red"] = field.construct_field("string")
     self.properties["green"] = field.construct_field("string")
     self.properties["blue"] = field.construct_field("string")
Example #11
0
 def __init__(self, *args, **kwargs):
     super(ColorField, self).__init__(*args, **kwargs)
     self.properties["red"] = field.construct_field("string")
     self.properties["green"] = field.construct_field("string")
     self.properties["blue"] = field.construct_field("string")
Example #12
0
def test_field_from_dict():
    f = field.construct_field({"type": "text", "index": "not_analyzed"})

    assert isinstance(f, field.Text)
    assert {"type": "text", "index": "not_analyzed"} == f.to_dict()
Example #13
0
 def __init__(self, *args, **kwargs):
     super(SlugObjectField, self).__init__(*args, **kwargs)
     self.properties['slug'] = field.construct_field('string', index='not_analyzed')
def test_field_from_dict():
    f = field.construct_field({"type": "string", "index": "not_analyzed"})

    assert isinstance(f, field.String)
    assert {"type": "string", "index": "not_analyzed"} == f.to_dict()
def test_alias_field_from_dict():
    f = field.construct_field({"type": "alias", "path": "followers_count"})

    assert isinstance(f, field.Alias)
    assert {"type": "alias", "path": "followers_count"} == f.to_dict()