Search for multiple values of same field in elasticsearch -


i have schema this

[{'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/'}] 

now want query on url find both occurance of url either http or https.

as url http://www.theage.com.au/victoria/ both http , https version saved want discard.

i searched bit , wrote query not giving adequate results.

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                            } }                              }                        ) 

in this

url = http://www.networkworld.com/article/3028099/security/ final_url = https://www.networkworld.com/article/3028099/security/

i getting empty , no results matching should 1 of them.

try query

if data field url analyzed work:

{    "query": {          "query_string": {                     "query": "url: (http or https) "             }    } } 

also while using slashes in query make sure escape them.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -