我的索引 python 文件下面
应该有 7 个匹配基于真实数据的查询,但它一直产生 10 个结果。因为默认大小参数是 10 有没有办法让它产生与点击次数一样多的次数而不是大小?还是我必须预测大小并一直将其放入查询中?
结果:
也许与我如何索引它有关?idk 为什么总命中数是 26639。它应该像 7 一样匹配。
from elasticsearch import helpers, Elasticsearch
from datetime import datetime
import csv
import json
es = Elasticsearch()
with open('result.csv', encoding='utf-8') as f:
reader = csv.DictReader(f)
helpers.bulk(es, reader, index='hscate', doc_type='my-type')
res = es.search(index = 'hscate',
doc_type = 'my-type',
# size ='1000',
#from_=0,
body = {
'query': {
'match' : {
'name' : '추성훈의 코몽트 기모본딩바지 3+1종_총 4종'
}
}
})
print(len(res['hits']['hits']))
with open('mycsvfile.csv', 'w',encoding='utf-8',newline='') as f: # Just use 'w' mode in 3.x
header_present = False
for doc in res['hits']['hits']:
my_dict = doc['_source']
if not header_present:
w = csv.DictWriter(f, my_dict.keys())
w.writeheader()
header_present = True
w.writerow(my_dict)
眼眸繁星
守候你守候我
相关分类