lhq commited on
Commit
fa4f24e
1 Parent(s): 2707b71

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -1
README.md CHANGED
@@ -33,4 +33,34 @@ configs:
33
  ---
34
  # Dataset Card for "es_indexing_benchmark"
35
 
36
- [More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ---
34
  # Dataset Card for "es_indexing_benchmark"
35
 
36
+ Here is a code on how to pull and index this dataset to elasticsearch:
37
+
38
+ ```python
39
+ import datasets
40
+ from tqdm import tqdm
41
+
42
+ from src.store.es.search import ESBaseClient
43
+ from src.store.es.model import ESNode
44
+
45
+ ds = datasets.load_dataset('stellia/es_indexing_benchmark', split='train', ignore_verifications=True)
46
+ client = ESBaseClient()
47
+
48
+
49
+ index_name = "tmp_es_index"
50
+ nodes = []
51
+ for row in tqdm(ds):
52
+ esnode = ESNode(**row)
53
+ esnode.meta.id = esnode.block.id
54
+ nodes.append(esnode)
55
+
56
+
57
+ client.delete_index(index_name)
58
+ client.init_index(index_name)
59
+
60
+ batch_size = 5000
61
+ for i in tqdm(range(0, len(nodes), batch_size)):
62
+ client.save(index_name, nodes[i:i+batch_size], refresh=False)
63
+ ```
64
+
65
+
66
+ Consider empty `~/.cache/huggingface/datasets` with `rm -rf ~/.cache/huggingface/datasets` if you have problem loading the dataset.