-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
87 lines (71 loc) · 1.81 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from es_practice import es_practice_hz
from CSVtoJSON import formatConverter
# doc3 = {
# "id" : 1 ,
# "name" : "Dell Inspiron 5500" ,
# "brand" : "HP" ,
# "price": 50000,
# "attributes" : [
# {"attribute_name": "cpu" , "attribute_value" : "Intel Core i5"
# },
# {"attribute_name":"RAM" , "attribute_value":"8GB" },
# {"attribute_name":"storage" , "attribute_value":"500GB" },],
# }
new_database = es_practice_hz() #creating a client and connecting to the server, if we run this
#multiple times no problem as only multiple clients would be created.
# helperClass = formatConverter(["id", "name", "price", "brand", "cpu", "memory", "storage"], "dell_laptop")
# converted_data = helperClass.convert_format("laptops_data.csv")
# new_database.bulk_doc_create(converted_data , "dell_laptop")
search_query1 = {
"query": {
"match":{
"brand" : "HP"
}
}
}
search_query2 = {
"query": {
"range" : {
"price": {
"gte": 50000,
"lte": 100000
}
}
}
}
search_query3 = {
"query": {
"bool": {
"must": [
{
"match": {
"brand": "HP"
}
}
]
, "should": [
{"match": {
"attribute_value": "Intel Core i7"
}
},
]
, "filter": [ {
"range" : {
"price": {
"gte": 50000,
"lte": 100000
}
}
}
]
}}}
search_query4 = {
"query": {
"match":{
"brand" : "HP"
}
}
}
#new_database.delete_index("dell_laptop")
new_database.list_allIndex()
print (new_database.search_data( "dell_laptop" ,search_query4))