提交 71253052 作者: 薛凌堃

es工具

上级 91b061ca
...@@ -18,7 +18,6 @@ class EsMethod(object): ...@@ -18,7 +18,6 @@ class EsMethod(object):
self.index_name='researchreportdata' self.index_name='researchreportdata'
''' '''
模糊 模糊
# 查询方法:模糊查询(会被分词)。 # 查询方法:模糊查询(会被分词)。
...@@ -163,55 +162,22 @@ class EsMethod(object): ...@@ -163,55 +162,22 @@ class EsMethod(object):
'query': { 'query': {
'bool': { 'bool': {
'should':[ 'should':[
{'term':{'labels.relationId' : '91110108740053589U'}}, # {'term':{'origin' : '雪球网'}},
{'term':{'type' : 3}}, {'term':{'type' : 1}},
], ],
# 'must': [ 'must': [
# {'match': {'title': '.pdf'}} {'match': {'title': '.pdf'}}
# ]
}
},
'from' : pnum,
'size' : 600,
}
body = {
"query": {
"bool": {
"must": [
{
"nested": {
"path": "labels",
"query": {
"match": {
"labels.relationId": "91110108740053589U"
}
}
}
},
{
"term": {
"type.keyword": {
"value": "3"
}
}
}
] ]
} }
}, },
"sort": [ 'from' : pnum,
{ 'size' : 6000,
"publishDate": {
"order": "desc"
}
}
],
"track_total_hits": True,
"size": 212
} }
filter_path=['hits.hits._source.title', # 字段1 filter_path=['hits.hits._source.title', # 字段1
'hits.hits._source.id', 'hits.hits._source.id',
'hits.total.value', 'hits.total.value',
'hits.hits._source.type',
] # 字段2 ] # 字段2
result = self.es.search(index=index_name result = self.es.search(index=index_name
,doc_type='_doc' ,doc_type='_doc'
...@@ -240,6 +206,8 @@ class EsMethod(object): ...@@ -240,6 +206,8 @@ class EsMethod(object):
print(fields) print(fields)
if __name__ == '__main__': if __name__ == '__main__':
esMethod=EsMethod() esMethod=EsMethod()
# esMethod.getFileds(index_name=esMethod.index_name) # esMethod.getFileds(index_name=esMethod.index_name)
...@@ -255,8 +223,8 @@ if __name__ == '__main__': ...@@ -255,8 +223,8 @@ if __name__ == '__main__':
title=mms['_source']['title'] title=mms['_source']['title']
utitle=title.replace('.pdf','') utitle=title.replace('.pdf','')
print(f'id:{id}---title:{title}--utitle:{utitle}') print(f'id:{id}---title:{title}--utitle:{utitle}')
# esMethod.updateaunn(esMethod.index_name,str(id),utitle) esMethod.updateaunn(esMethod.index_name,str(id),utitle)
esMethod.delete(esMethod.index_name,str(id)) # esMethod.delete(esMethod.index_name,str(id))
print('跟新成功!!') print('跟新成功!!')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论