我在具有以下结构的ElasticSearch中创建了索引
{
"took": 17,"timed_out": false,"_shards": {
"total": 1,"successful": 1,"skipped": 0,"failed": 0
},"hits": {
"total": {
"value": 9,"relation": "eq"
},"max_score": 1.0,"hits": [
{
"_index": "my_index2","_type": "_doc","_id": "ou57P24BbiLEFIdnhkkg","_score": 1.0,"_source": {
"name": "Hung Le","age": "34"
}
},{
"_index": "my_index2","_id": "o-57P24BbiLEFIdnx0kj","_source": {
"name": "Viet Pham","age": "20"
}
},"_id": "pO58P24BbiLEFIdnAUm-","_source": {
"name": "Quy Tran","age": "21"
}
},"_id": "pe58P24BbiLEFIdnJ0mn","_source": {
"name": "Khiem Pham","age": "22"
}
},"_id": "pu58P24BbiLEFIdngUnX","_source": {
"name": "PhamHoangViet","_id": "p-59P24BbiLEFIdnPUma","_source": {
"name": "Nguyễn Trần Trung Quân","_id": "qO59P24BbiLEFIdnbkkO","_source": {
"name": "Đặng Tấn Sĩ","_id": "qe5_P24BbiLEFIdnDknH","_source": {
"name": "Văn Trung","_id": "qu5_P24BbiLEFIdnZkm3","_source": {
"name": "Phạm Nguyễn Minh Quân","age": "34"
}
}
]
}
}
这是我的数据:
http://localhost:9200/my_index2/_search?q=name:Trung+Quân
我用关键字“ TrungQuân”进行搜索:
{
"took": 6,"hits": {
"total": {
"value": 3,"max_score": 2.19989,"_score": 2.19989,"_score": 1.497693,"_score": 1.099945,"age": "34"
}
}
]
}
}
结果如下:
{
"took": 9,"hits": {
"total": {
"value": 2,"max_score": 2.6052008,"_score": 2.6052008,"age": "21"
}
}
]
}
}
它将检索包含单词“ Trung”或单词“Quân”的所有结果。现在,我必须如何配置索引,以便结果包含以下内容的“ Trung”和“Quân”:
from collections import Counter
import time
#10 sec
t_end = time.time() + 10
arr = []
while time.time() < t_end:
#print(time.time())
arr.append(random.randint(0,100))
arr = Counter(arr)
print(arr.most_common(3))