Beispiel #1
0
    def setUp(self):
        settings = {
            'DOMAIN': {
                'items': {
                    'schema': {
                        'slugline': {
                            'type': 'string',
                            'mapping': {
                                'type': 'string',
                                'fields': {
                                    'phrase': {
                                        'type': 'string',
                                        'index_analyzer':
                                        'phrase_prefix_analyzer',
                                        'search_analyzer':
                                        'phrase_prefix_analyzer'
                                    }
                                }
                            }
                        }
                    },
                    'datasource': {
                        'backend': 'elastic'
                    }
                }
            },
            'ELASTICSEARCH_URL': 'http://localhost:9200',
            'ELASTICSEARCH_INDEX': self.index_name,
            'ELASTICSEARCH_SETTINGS': ELASTICSEARCH_SETTINGS
        }

        self.app = eve.Eve(settings=settings, data=Elastic)
        self.app.data.init_index(self.app)
        with self.app.app_context():
            for resource in self.app.config['DOMAIN']:
                self.app.data.remove(resource)

            self.es = get_es(self.app.config.get('ELASTICSEARCH_URL'))
Beispiel #2
0
    def setUp(self):
        settings = {
            'DOMAIN': {
                'items': {
                    'schema': {
                        'slugline': {
                            'type': 'string',
                            'mapping': {
                                'type': 'string',
                                'fields': {
                                    'phrase': {
                                        'type': 'string',
                                        'index_analyzer': 'phrase_prefix_analyzer',
                                        'search_analyzer': 'phrase_prefix_analyzer'
                                    }
                                }
                            }
                        }
                    },
                    'datasource': {
                        'backend': 'elastic'
                    }
                }
            },
            'ELASTICSEARCH_URL': 'http://localhost:9200',
            'ELASTICSEARCH_INDEX': self.index_name,
            'ELASTICSEARCH_SETTINGS': ELASTICSEARCH_SETTINGS
        }

        self.app = eve.Eve(settings=settings, data=Elastic)
        with self.app.app_context():
            self.app.data.init_index(self.app)
            for resource in self.app.config['DOMAIN']:
                self.app.data.remove(resource)

            self.es = get_es(self.app.config.get('ELASTICSEARCH_URL'))
Beispiel #3
0
    def test_serializer_config(self):
        class TestSerializer(elasticsearch.JSONSerializer):
            pass

        es = get_es('http://localhost:9200', serializer=TestSerializer())
        self.assertIsInstance(es.transport.serializer, TestSerializer)
Beispiel #4
0
 def test_cluster(self):
     es = get_es(['http://localhost:9200', 'http://localhost:9200'])
     self.assertIsNotNone(es)