tgrez / sejm-ngram

visualization of trends in the use of words and phrases in the parliament
http://www.sejmotrendy.pl
12 stars 4 forks source link

elasticsearch - Bulk-insert #64

Open ad-m opened 9 years ago

ad-m commented 9 years ago
curl -s -XPOST localhost:9200/_bulk --data-binary @requests; echo

(por. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html )

siemionides commented 8 years ago

@tgrez @ad-m don't we already have a python script that inserts data in https://github.com/tgrez/sejm-ngram/blob/master/scripts/elasticsearch/build_index_main.py ? Can I close this ticket or is it some improvement?

ad-m commented 8 years ago

W mojej ocenie jest to istotne usprawnienie, bo tworzysz jedno połączenie i przesyłasz odpowiednią ilość danych jednym żądaniem HTTP, które są importowane w trakcie przesyłania. Obawiam się, że skrypt w Pythonie będzie działać wolniej, bo w wielu żądaniach HTTP.

Jak to pisałem to widziałem skrypt w Pythonie, ale nie robiłem testów wydajności.

@mik-laj, może masz uwagi?

mik-laj commented 8 years ago

@siemionides w tym skrypie brakuje obsługi bulk insert. Jest do tego specjalne API. Wtedy by było dużo dużo wydajniej

actions = [{'_id': 1}, {'_id': 2}]
helpers.streaming_bulk(self.client, actions, index='test-index', doc_type='answers'):

(src: http://nullege.com/codes/show/src@e@l@elasticsearch-py-HEAD@test_elasticsearch@test_server@test_helpers.py/30/elasticsearch.helpers.streaming_bulk)

Jest to proste, ale trzeba się wziaść. Moim zdaniem warto to napisać.