ajosh0504 commited on
Commit
3923844
·
verified ·
1 Parent(s): 7287aa7

Restore full dataset card

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md CHANGED
@@ -27,3 +27,47 @@ The dataset consists of the following fields:
27
  - metadata: Metadata such as tags, content type etc. associated with the document.
28
  - title: Title of the document.
29
  - updated: The last updated date of the document.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  - metadata: Metadata such as tags, content type etc. associated with the document.
28
  - title: Title of the document.
29
  - updated: The last updated date of the document.
30
+
31
+ ## Usage
32
+
33
+ This dataset can be useful for prototyping RAG applications. This is a real sample of data we have used to build the MongoDB Documentation Chatbot.
34
+
35
+ ## Ingest Data
36
+
37
+ To experiment with this dataset using MongoDB Atlas, first [create a MongoDB Atlas account](https://www.mongodb.com/cloud/atlas/register?utm_campaign=devrel&utm_source=community&utm_medium=organic_social&utm_content=Hugging%20Face%20Dataset&utm_term=apoorva.joshi).
38
+
39
+ You can then use the following script to load this dataset into your MongoDB Atlas cluster:
40
+
41
+ ```
42
+ import os
43
+ from pymongo import MongoClient
44
+ import datasets
45
+ from datasets import load_dataset
46
+ from bson import json_util
47
+
48
+ uri = os.environ.get('MONGODB_ATLAS_URI')
49
+ client = MongoClient(uri)
50
+ db_name = 'your_database_name' # Change this to your actual database name
51
+ collection_name = 'mongodb_docs'
52
+
53
+ collection = client[db_name][collection_name]
54
+
55
+ dataset = load_dataset("MongoDB/mongodb-docs")
56
+
57
+ insert_data = []
58
+
59
+ for item in dataset['train']:
60
+ doc = json_util.loads(json_util.dumps(item))
61
+ insert_data.append(doc)
62
+
63
+ if len(insert_data) == 1000:
64
+ collection.insert_many(insert_data)
65
+ print("1000 records ingested")
66
+ insert_data = []
67
+
68
+ if len(insert_data) > 0:
69
+ collection.insert_many(insert_data)
70
+ insert_data = []
71
+
72
+ print("Data ingested successfully!")
73
+ ```