Created
August 8, 2016 14:35
-
-
Save ruanbekker/48ad53898bc23e2c585752ee67b7d82a to your computer and use it in GitHub Desktop.
generates random data and pushes to elasticsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from faker import Factory | |
from datetime import datetime | |
from elasticsearch import Elasticsearch | |
import json | |
esDomainEndpoint = "http://search-endpoint:80" | |
es = Elasticsearch(esDomainEndpoint) | |
def create_names(fake): | |
for x in range(100): | |
genUname = fake.slug() | |
genName = fake.name() | |
genJob = fake.job() | |
genCountry = fake.country() | |
genText = fake.text() | |
genProfile = fake.profile() | |
go = es.index( | |
index="profiles", | |
doc_type="users", | |
id=genUname, | |
body={ | |
"name": genName, | |
"job": genJob, | |
"country": genCountry, | |
"notes": genText, | |
"profile_details": genProfile, | |
"timestamp": datetime.now() | |
} | |
) | |
print json.dumps(go) | |
if __name__ == '__main__': | |
fake = Factory.create() | |
create_names(fake) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment