python - Exclude items from results -


i'm using elasticsearch search mongodb python. i'd give query list of item ids in order exclude them search results.

i tried query no results:

flagged_articles = ["er12", "rt43"] query = {      "from": page*limit,     "size": limit,     "query": {         "bool": {             "must": {                 "range": {                     "added" : {                         "from" : "2013-04-11t00:00:00"                     }                 }           },           "ids" : {             "values" : flagged_articles           }     } 

it faster if did filter rather query. filter doesn't score calculation , has lighter overhead.

{     "filtered" : {         "query" : {             "range": {                 "added" : {                     "from" : "2013-04-11t00:00:00"                 }             }         },         "filter" : {             "not" : {                 "filter" : {                     "ids" : {                         "values" : ["123", "456", "789"]                     }                 },                 "_cache" : true             }         }     } } 

note: not filter not cached default (the other filters cached). i've added _cache: true parameter show have cache not filter if think using on subsequent searches.

good luck!