コード例 #1
0
    def test_bulk_index(self):
        documents = [
            {'id': 1, 'name': 'odin skullcrusher'},
            {'id': 2, 'name': 'heimdall kneebiter'},
            {'id': 3, 'name': 'erik rose'}
            ]

        # Generate the FakeModel in our "database"
        for doc in documents:
            FakeModel(**doc)

        # Index the document with .index()
        FakeDjangoMappingType.bulk_index(documents, id_field='id')

        self.refresh(FakeDjangoMappingType.get_index())

        # Query it to make sure they're there.
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1)
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='erik')), 1)
コード例 #2
0
    def test_bulk_index(self):
        documents = [
            {"id": 1, "name": "odin skullcrusher"},
            {"id": 2, "name": "heimdall kneebiter"},
            {"id": 3, "name": "erik rose"},
        ]

        # Generate the FakeModel in our "database"
        for doc in documents:
            FakeModel(**doc)

        # Index the document with .index()
        FakeDjangoMappingType.bulk_index(documents, id_field="id")

        self.refresh(FakeDjangoMappingType.get_index())

        # Query it to make sure they're there.
        eq_(len(S(FakeDjangoMappingType).query(name__prefix="odin")), 1)
        eq_(len(S(FakeDjangoMappingType).query(name__prefix="erik")), 1)
コード例 #3
0
    def test_bulk_index(self):
        documents = [{
            'id': 1,
            'name': 'odin skullcrusher'
        }, {
            'id': 2,
            'name': 'heimdall kneebiter'
        }, {
            'id': 3,
            'name': 'erik rose'
        }]

        # Generate the FakeModel in our "database"
        for doc in documents:
            FakeModel(**doc)

        # Index the document with .index()
        FakeDjangoMappingType.bulk_index(documents, id_field='id')

        self.refresh(FakeDjangoMappingType.get_index())

        # Query it to make sure they're there.
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='odin')), 1)
        eq_(len(S(FakeDjangoMappingType).query(name__prefix='erik')), 1)