2017-04-24 152 views
0

我试图运行,像这样定义的elasticsearch查询:弹性搜索布尔查询错误

query = { 
    "query": { 
     "bool": { 
      "should": [ 
       {"term": {"a": "a1"}}, 
       {"term": {"b": "b1"}}, 
       {"term": {"c": "c1"}}  
      ], 
     }, 
    }, 
} 

es.search("my_index", body=q1) 

,但我得到了以下错误:

RequestError: TransportError(400, 'search_phase_execution_exception',   
'failed to create query: 
... 

什么是与查询问题?

回答

0

它可能无法解析JSON,因为您的数组中有一个尾随逗号。 (并且在每个查询和布尔属性之后还有一对)JSON规范不允许使用多余的尾随逗号。

0

尝试这样的: -

{ 
    "query": { 
     "bool": { 
      "should": [ 
       {"term": {"a": "a1"}}, 
       {"term": {"b": "b1"}}, 
       {"term": {"c": "c1"}}  
      ] 
     } 
    } 
}