我有这样的模式
[{'author': 'edsec',
'awesomeness': 3,
'date': '2017-09-12T07:22:50.033712',
'url': 'http://nakedsecurity.sophos.com/2016/02/11/'},
{'author': '.thea',
'awesomeness': 2,
'date': '2017-09-12T08:22:49.969594',
'url': 'http://www.theage.com.au/victoria/'},
{'author': '.chic',
'awesomeness': 1,
'date': '2017-09-12T09:22:49.896584',
'url': 'http://www.chicagotribune.com/news/'},
{'author': '://ww',
'awesomeness': 1,
'date': '2017-09-12T10:19:58.723068',
'url': 'https://www.theage.com.au/victoria/'},
{'author': '://ww',
'awesomeness': 0,
'date': '2017-09-12T11:19:58.656548',
'url': 'https://www.networkworld.com/article/3028099/security/'},
{'author': '://av',
'awesomeness': 0,
'date': '2017-09-12T12:19:57.589412',
'url': 'https://avien.net/blog/educational-ransomware/'}]
现在我想查询 url 以查找 url 与 http 或 https 的出现。
关于 url http://www.theage.com.au/victoria/我想丢弃的 http 和 https 版本都已保存。
我进行了一些搜索并编写了查询,但没有给出足够的结果。
result = es.search(index='blogs', doc_type='text',
body={
"size": 10,
"query": {"bool":{
"should":[
{"term": {"url": final_url}},
{"term": {"url": url}}],
"minimum_should_match" : 1,
"boost" : 1.0
} }
}
)
在这
网址 = http://www.networkworld.com/article/3028099/security/ final_url = https://www.networkworld.com/article/3028099/security/
我变空了,没有匹配的结果,我应该得到其中一个。
最佳答案
我自己得到了答案
result = es.search(index=self.es_index, doc_type='abc',
body={"query": {"bool":{
"must":[
{"match": {"url": url}},
{"match": {"url": url2}}],
} }})
关于elasticsearch - 在elasticsearch中搜索同一字段的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46170309/