弹性搜索 - 查询值

时间:2012-10-18 19:47:47

标签: 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 个答案:

答案 0 :(得分: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" }
            }
        }
    }
}'
相关问题