2017-09-26 25 views
0

我對elasticsearch和Linux都是全新的。由於2周前的一個項目,我開始瞭解他們。所以,如果我的問題太簡單,很抱歉。 我試圖編寫一個查詢來幫助我找出根據存儲庫中的關鍵字列表(8000個關鍵字)返回的唯一記錄的數量,這是2個星期。下面是我提出的代碼搭配:使用超過8000個關鍵字編寫查詢以檢索包含這些關鍵字的唯一記錄

curl http://localhost:9200/INDEXED_REPOSITORY/_search?q="constant_score" : {"filter" : { "terms" : { "description" : ["heart", "cancer", and 7000 more keywords that I just pasted here]}}}} 

,但我得到了以下錯誤:

Couldn't resolve host 'constant_score' 
curl: (6) Couldn't resolve host ':' 
curl: (3) [globbing] unmatched brace at pos 8 

curl: (6) Couldn't resolve host ':' 
curl: (3) [globbing] unmatched brace at pos 2 

curl: (6) Couldn't resolve host 'terms' 
curl: (6) Couldn't resolve host ':' 
curl: (3) [globbing] unmatched brace at pos 2 

我不明白我在做什麼錯。有沒有解決這個問題的方法?

+0

您可能需要URL編碼查詢「Q」,這就是爲什麼你看到的錯誤,如「捲曲:(6)無法解析主機‘條款’」 – printfmyname

+0

@printfmyname做什麼你的意思是通過編碼q?你可以請直接給我一些關於這個教程? – NinaDev

+0

我認爲這回答你的問題https://unix.stackexchange.com/questions/86729/any-way-to-encode-the-url-in-curl-command。只要確保你有一切從'q'開始到'}'在引號內。因爲您已經使用「雙引號,使用單引號」來包裝您的日期 – printfmyname

回答

0

我更喜歡使用curl的-d選項而不是查詢字符串來傳遞查詢。 這應該工作:

curl -XGET "http://localhost:9200/INDEXED_REPOSITORY/_search" -d' 
{ 
    "query": { 
    "constant_score": { 
     "filter": { 
     "terms": { 
      "description": [ 
      "heart", 
      "cancer" 
      ] 
     } 
     } 
    } 
    } 
}' 
相關問題