2012-10-18 158 views
1

我有以下值的elasticsearch指數彈性搜索 - 查詢價值觀

{ 
    "_index": "article", 
    "_type": "articleId", 
    "_id": "10970", 
    "_score": 1, 
    "_source": { 
     "url": "http%3A%2F%2Fwww.tomshardware.com%2Fnews%2FAir-Traffic-Software-DoS-Attacks%2C16471.html%23xtor%3DRSS-181", 
     "title": "Air%20Traffic%20Software%20Vulnerable%20to%20DoS%20Attacks", 
     "publicationId": "888", 
     "text": "%20%3Cp%3E%3Cstrong%3EA%20security%20researcher%20revealed%20a%20flaw%20in%20commonly%20used%20air%20traffic%20control%20software%20that%20would%20allow%20an%20attacker%20to%20create%20an%20unlimited%20number%20of%20phantom%20flights.%3C%2Fstrong%3E%3C%2Fp%3E%20%3Cp%3E%3Ca%20target%3D%22_blank%22%3E%3C%2Fa%3E%3C%2Fp%3E%20%3Cp%3EAccording%20to%20Andrei%20Costin%2C%20%242%2C000%20in%20equipment%20and%20%22modest%20tech%20skills%22%20are%20enough%20to%20throw%20an%20air%20traffic%20control%20system%20of%20virtually%20any%20airport%20into%20complete%20disarray.%20The%20ADS-B%20system%20that%20is%20used%20across%20the%20world%20is%20vulnerable%20as%20it%20does%20not%20verify%20that%20incoming%20traffic%20signals%20as%20genuine.%20%3C%2Fp%3E%20%3Cp%3ECostin%20says%20that%20a%20hacker%20could%20inject%20flights%20that%20do%20not%20exist%20and%20could%20confuse%20an%20air%20controller%20station.%20Air%20controllers%20could%20cross-check%20flights%20with%20flight%20schedules%2C%20but%20if%20the%20number%20of%20phantom%20flights%20is%20high%20enough%2C%20there%20is%20no%20way%20that%20cross-checks%20would%20work.%20Consider%20it%20like%20an%20DoS%20attack%20on%20an%20air%20traffic%20control%20system.%3C%2Fp%3E%20%3Cp%3ECostin%20noted%20that%20rogue%20signals%20from%20the%20ground%20can%20be%20generally%20identified%20and%20ruled%20out%20as%20malicious%20signals%2C%20but%20there%20is%20no%20way%20to%20do%20the%20same%20for%20robotic%20aircraft%2C%20for%20example.%20He%20also%20noted%20that%20data%20sent%20from%20airplanes%20to%20air%20traffic%20controllers%20is%20unencrypted%20and%20can%20be%20captured%20by%20unidentified%20sources.%20Since%20this%20applies%20to%20any%20aircraft%2C%20it%20is%20in%20theory%20possible%20to%20deploy%20airplane%20tracking%20devices%20to%20track%20specific%20aircraft.%3C%2Fp%3E%20%3C%2Fp%3E%3Cp%3E%20%3Cp%3E%3Ca%20target%3D%22_blank%22%20href%3D%22mailto%3Anews-us%40bestofmedia.com%3Fsubject%3DNews%2520Article%2520Feedback%22%3E%3Cem%3E%3Csub%3EContact%20Us%20for%20News%20Tips%2C%20Corrections%20and%20Feedback%3C%2Fsub%3E%3C%2Fem%3E%3C%2Fa%3E%3C%2Fp%3E", 
     "keywords": { 
      "air": "3.4965034965034962", 
      "traffic": "3.4965034965034962", 
      "flights": "2.797202797202797", 
      "": "2.797202797202797", 
      "Costin": "2.097902097902098", 
      "aircraft": "2.097902097902098", 
      "signals": "2.097902097902098", 
      "control": "2.097902097902098", 
      "system": "2.097902097902098", 
      "there": "1.3986013986013985" 
     } 
    } 
} 

我想編寫一個查詢來搜索並此索引的關鍵字是航班(其中它),但我有難度 其直接的像文字等領域的一個運行匹配查詢,但試圖做相同或關鍵字

相似時遇到的問題是否與當前的設置執行此搜索方式或者我應該添加不同的關鍵字?

回答

1

如果我正確理解了你的話,你想找到所有具有keyword.flights字段的記錄,這個字段的值並不重要。

curl "http://localhost:9200/_search?q=keywords.flights:*" 

或者使用exist filter

curl "http://localhost:9200/_search" -d '{ 
    "query": { 
     "constant_score" : { 
      "filter" : { 
       "exists" : { "field" : "keywords.flights" } 
      } 
     } 
    } 
}' 
可以使用查詢字符串做