2016-11-14 198 views

回答

13

您需要使用NOT operator,就像這樣:

!(name:"Fred") 

NOT (name:"Fred") 
14

你應該使用must_not聲明布爾查詢

{ 
    "query": { 
    "bool" : { 
     "must_not" : { 
     "term" : { 
      "name" : "Fred" 
     } 
     } 
    } 
    } 
} 
0

和,或不過濾器

and: 

{ 
    "filtered" : { 
     "query" : { 
      "term" : { "name.first" : "shay" } 
     }, 
     "filter" : { 
      "and" : { 
       "filters" : [ 
        { 
         "term" : { "name.first" : "something" } 
        }, 
        { 
         "term" : { "name.first" : "other" } 
        } 
       ] 
      } 
     } 
    } 
} 
or: 

{ 
    "filtered" : { 
     "query" : { 
      "term" : { "name.first" : "shay" } 
     }, 
     "filter" : { 
      "or" : { 
       "filters" : [ 
        { 
         "term" : { "name.first" : "something" } 
        }, 
        { 
         "term" : { "name.first" : "other" } 
        } 
       ] 
      } 
     } 
    } 
} 
not: 

{ 
    "filtered" : { 
     "query" : { 
      "term" : { "name.first" : "shay" } 
     }, 
     "filter" : { 
      "not" : { 
       "filter" : { 
        "term" : { "name.first" : "someting" } 
       } 
      } 
     } 
    } 
}