from datetime import datetime
from pytz import timezone

from elasticsearch_dsl import DocType, Date, String, construct_field, Mapping

user_field = construct_field('object')
user_field.field(
    'name',
    'string',
    fields={'raw': construct_field('string', index='not_analyzed')})


class Repository(DocType):
    owner = user_field
    created_at = Date()
    description = String(analyzer='snowball')
    tags = String(index='not_analyzed')

    class Meta:
        index = 'git'
        doc_type = 'repos'


class Commit(DocType):
    committed_date = Date()
    authored_date = Date()
    description = String(analyzer='snowball')

    class Meta:
        index = 'git'
        mapping = Mapping('commits')
from datetime import datetime

from elasticsearch_dsl import DocType, Date, String, construct_field

user_field = construct_field('object')
user_field.property('name', 'string', fields={'raw': construct_field('string', index='not_analyzed')})

class Repository(DocType):
    owner = user_field
    created_at = Date()
    description = String(analyzer='snowball')
    tags = String(index='not_analyzed')

    class Meta:
        index = 'git'
        doc_type = 'repos'

def test_init(write_client):
    Repository.init(index='test-git')

    assert write_client.indices.exists_type(index='test-git', doc_type='repos')

def test_get(data_client):
    elasticsearch_repo = Repository.get('elasticsearch-dsl-py')

    assert isinstance(elasticsearch_repo, Repository)
    assert elasticsearch_repo.owner.name == 'elasticsearch'
    assert datetime(2014, 3, 3) == elasticsearch_repo.created_at

def test_save_updates_existing_doc(data_client):
    elasticsearch_repo = Repository.get('elasticsearch-dsl-py')
예제 #3
0
from datetime import datetime
from pytz import timezone

from elasticsearch import ConflictError, NotFoundError, RequestError

from elasticsearch_dsl import DocType, Date, Text, Keyword, construct_field, Mapping
from elasticsearch_dsl.utils import AttrList

from pytest import raises

user_field = construct_field('object')
user_field.field('name', 'text', fields={'raw': construct_field('keyword')})


class Wiki(DocType):
    owner = user_field

    class Meta:
        index = 'test-wiki'


class Repository(DocType):
    owner = user_field
    created_at = Date()
    description = Text(analyzer='snowball')
    tags = Keyword()

    @classmethod
    def search(cls):
        return super(Repository, cls).search().filter('term',
                                                      commit_repo='repo')
예제 #4
0
from datetime import datetime
from pytz import timezone

from elasticsearch import ConflictError, NotFoundError

from elasticsearch_dsl import DocType, Date, String, construct_field, Mapping
from elasticsearch_dsl.utils import AttrList

from pytest import raises

user_field = construct_field('object')
user_field.field('name', 'string', fields={'raw': construct_field('string', index='not_analyzed')})

class Repository(DocType):
    owner = user_field
    created_at = Date()
    description = String(analyzer='snowball')
    tags = String(index='not_analyzed')

    class Meta:
        index = 'git'
        doc_type = 'repos'

class Commit(DocType):
    committed_date = Date()
    authored_date = Date()
    description = String(analyzer='snowball')

    class Meta:
        index = 'git'
        mapping = Mapping('commits')
from datetime import datetime
from pytz import timezone

from elasticsearch import ConflictError, NotFoundError, RequestError

from elasticsearch_dsl import DocType, Date, Text, Keyword, construct_field, Mapping
from elasticsearch_dsl.utils import AttrList

from pytest import raises

user_field = construct_field('object')
user_field.field('name', 'text', fields={'raw': construct_field('keyword')})

class Repository(DocType):
    owner = user_field
    created_at = Date()
    description = Text(analyzer='snowball')
    tags = Keyword()

    class Meta:
        index = 'git'
        doc_type = 'repos'

class Commit(DocType):
    committed_date = Date()
    authored_date = Date()
    description = Text(analyzer='snowball')

    class Meta:
        index = 'git'
        mapping = Mapping('commits')