예제 #1
0
def elastic_seeker1():
    BookDoc = seeker.document_from_model(models.Book, index="seeker-tests", using=models.client)
    seeker.register(BookDoc)
    s = BookDoc.search()
    s = s.query("match_all")
    books = s.execute()
    for book in books:
        print(book.meta.score, book.authors)
    models.BookDoc = BookDoc
예제 #2
0
import elasticsearch_dsl as dsl

import seeker

from .external import BaseDocument
from .models import Book, Magazine


BookDocument = seeker.document_from_model(Book, module=__name__)
MagazineDocument = seeker.document_from_model(Magazine, module=__name__)


class DjangoBookDocument (seeker.ModelIndex):

    class Meta:
        mapping = seeker.build_mapping(Book, doc_type='django_book')

    @classmethod
    def queryset(cls):
        return Book.objects.filter(title__icontains='django')


class DerivedDocument (BaseDocument):
    derived_field = dsl.Integer()
예제 #3
0
from .models import Book, Magazine
import seeker

BookDocument = seeker.document_from_model(Book)
MagazineDocument = seeker.document_from_model(Magazine)

seeker.register(BookDocument)
seeker.register(MagazineDocument)
예제 #4
0
import elasticsearch_dsl as dsl

import seeker

from .external import BaseDocument
from .models import Book, Magazine


BookDocument = seeker.document_from_model(Book, module=__name__)
MagazineDocument = seeker.document_from_model(Magazine, module=__name__)


class DjangoBookDocument(seeker.ModelIndex):

    class Meta:
        mapping = seeker.build_mapping(Book)

    class Index:
        name = 'djangobook'

    @classmethod
    def queryset(cls):
        return Book.objects.filter(title__icontains='django')


class DerivedDocument(BaseDocument):
    derived_field = dsl.Integer()

    class Index:
        name = 'derived'
예제 #5
0
from .models import Book, Magazine
import seeker

BookDocument = seeker.document_from_model(Book)
MagazineDocument = seeker.document_from_model(Magazine)


class DjangoBookDocument(seeker.ModelIndex):
    class Meta:
        mapping = seeker.build_mapping(Book, doc_type='django_book')

    @classmethod
    def queryset(cls):
        return Book.objects.filter(title__icontains='django')


seeker.register(BookDocument)
seeker.register(MagazineDocument)
seeker.register(DjangoBookDocument)