Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_scatter(doc_type_name = "business"):
- answer = [[],[],[]]
- answer[0].append('Rating')
- answer[1].append('No. of Reviews')
- index_name = "content_engine_business"
- stars = [1.0,2.0,3.0,4.0,5.0]
- for k in range(len(stars)):
- temp =[]
- my_body={
- 'query' : {
- 'bool': {
- "must": [
- {"match" : {"stars":stars[k]}}
- ]
- }
- }
- }
- sample = es.search(index = index_name, body = my_body,size=5000)
- if sample['hits']['total'] > 5000:
- length = 5000
- else:
- length = sample['hits']['total']
- for el in sample['hits']['hits'][:1000]:
- random = el['_source']['review_count']
- name = el['_source']['name']
- answer[0].append(stars[k])
- answer[1].append(random)
- answer[2].append(name)
- return answer
- def get_scatter_city(statename, doc_type_name = "business"):
- answer = [[],[],[]]
- answer[0].append('Rating')
- answer[1].append('No. of Reviews')
- index_name = "content_engine_business"
- stars = [1.0,2.0,3.0,4.0,5.0]
- for k in range(len(stars)):
- temp =[]
- my_body={
- 'query' : {
- 'bool': {
- "must": [
- {"match" : {"stars":stars[k]}},
- {"match" : {"state": statename}}
- ]
- }
- }
- }
- sample = es.search(index = index_name, body = my_body,size=10000)
- if sample['hits']['total'] > 10000:
- length = 10000
- else:
- length = sample['hits']['total']
- for el in sample['hits']['hits'][:1000]:
- random = el['_source']['review_count']
- name = el['_source']['name']
- answer[0].append(stars[k])
- answer[1].append(random)
- answer[2].append(name)
- return answer
- def get_scatter_city_category(statename, category, doc_type_name = "business"):
- answer = [[],[],[]]
- answer[0].append('Rating')
- answer[1].append('No. of Reviews')
- index_name = "content_engine_business"
- stars = [1.0,2.0,3.0,4.0,5.0]
- if category == "misc":
- for k in range(len(stars)):
- temp =[]
- total_count = 0
- for l in range(len(misc)):
- my_body={
- 'query' : {
- 'bool': {
- "must": [
- {"match" : {"stars":stars[k]}},
- {"match" : {"state": statename}},
- {"match" : {"categories" : misc[l]}}
- ]
- }
- }
- }
- sample = es.search(index = index_name, body = my_body,size=10000)
- if sample['hits']['total'] > 10000:
- length = 10000
- else:
- length = sample['hits']['total']
- for el in sample['hits']['hits'][:1000]:
- random = el['_source']['review_count']
- name = el['_source']['name']
- answer[0].append(stars[k])
- answer[1].append(random)
- answer[2].append(name)
- else:
- for k in range(len(stars)):
- temp =[]
- my_body={
- 'query' : {
- 'bool': {
- "must": [
- {"match" : {"stars":stars[k]}},
- {"match" : {"state": statename}},
- {"match" : {"categories" : category}}
- ]
- }
- }
- }
- sample = es.search(index = index_name, body = my_body,size=10000)
- if sample['hits']['total'] > 10000:
- length = 10000
- else:
- length = sample['hits']['total']
- for el in sample['hits']['hits'][:1000]:
- random = el['_source']['review_count']
- name = el['_source']['name']
- answer[0].append(stars[k])
- answer[1].append(random)
- answer[2].append(name)
- print len(answer)
- print "3"
- return answer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement