2015-11-24 54 views
0

這個查詢 -無法搜索 '#' 在elasticsearch

curl -XGET http://localhost:9200/haystack/modelresult/_search?q=post_text:#test 

失敗,錯誤執行

SearchPhaseExecutionException[Failed to execute phase 

與狀態400

回答

1

試試這個:

curl -XPOST "http://localhost:9200/haystack/modelresult/_search" -d' 
{ 
    "query": { 
     "match": { 
      "post_text": "#test" 
     } 
    } 
}' 

或者這個:

curl -XPOST "http://localhost:9200/haystack/modelresult/_search" -d' 
{ 
    "query": { 
     "term": { 
      "post_text": "#test" 
     } 
    } 
}' 
+0

我認爲應該是** XGET ** – ChintanShah25

+0

ES也會接受。不過,有些客戶端不會讓你發送帶有GET請求的JSON數據。 –

+0

工作。我有另一個問題。如果我只想獲得包含'#test'的文檔的結果並忽略包含'test'的文檔,該怎麼辦? – Chipmunk