2017-09-01 39 views
0

我彈性搜索查詢有一些問題。當我使用查詢代碼時,它會反饋消息[bool]格式不正確的查詢,預計[END_OBJECT],但找到[FIELD_NAME]。布爾格格式錯誤的查詢,預計END_OBJECT,但發現FIELD_NAME

{ 
    "from":0, 
    "size":15, 
    "query":{ 
     "bool":{ 
     "must":[ 
      { 
       "multi_match":{ 
        "query":"books", 
        "fields":[ 
        "title^20", 
        "lead^10", 
        "content" 
        ], 
        "type":"phrase" 
       } 
      } 
     ] 
     }, 
     "must":{ 
     "match":{ 
      "groupid":"599e4b49239cfa0a5a5f189d" 
     } 
     } 
    }, 
    "sort":[ 
     { 
     "times":{ 
      "order":"desc" 
     } 
     } 
    ] 
} 

回答

2

你的第二個must子句不正確定位,它必須是現有的bool/must查詢中。您需要將您的查詢重寫爲:

{ 
    "from":0, 
    "size":15, 
    "query":{ 
     "bool":{ 
     "must":[ 
      { 
       "multi_match":{ 
        "query":"books", 
        "fields":[ 
        "title^20", 
        "lead^10", 
        "content" 
        ], 
        "type":"phrase" 
       } 
      }, 
      { 
       "match":{ 
        "groupid": "599e4b49239cfa0a5a5f189d" 
       } 
      } 
     ] 
     } 
    }, 
    "sort":[ 
     { 
     "times":{ 
      "order":"desc" 
     } 
     } 
    ] 
} 
相關問題