1

我想測試下面的指令彈性搜索:彈性搜索總是返回任何結果

http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-gsg.html

當我嘗試了上面並上傳下面的文字,這也是在指令:

{ 
    "index": { 
    "_index": "movies", 
    "_type": "listings", 
    "_id": "2" 
} 
} { 
"director": "Frankenheimer, John", 
"genre": ["Drama", "Mystery", "Thriller"], 
"year": 1962, 
"actor": ["Lansbury, Angela", "Sinatra, Frank", "Leigh, Janet", "Harvey, Laurence", "Silva, Henry", "Frees, Paul", "Gregory, James", "Bissell, Whit", "McGiver, John", "Parrish, Leslie", "Edwards, James", "Flowers, Bess", "Dhiegh, Khigh", "Payne, Julie", "Kleeb, Helen", "Gray, Joe", "Nalder, Reggie", "Stevens, Bert", "Masters, Michael", "Lowell, Tom"], 
"title": "The Manchurian Candidate" 
} { 
"index": { 
    "_index": "movies", 
    "_type": "listings", 
    "_id": "3" 
} 
} { 
"director": "Baird, Stuart", 
"genre": ["Action", "Crime", "Thriller"], 
"year": 1998, 
"actor": ["Downey Jr., Robert", "Jones, Tommy Lee", "Snipes, Wesley", "Pantoliano, Joe", "Jacob, Ir\u00e8ne", "Nelligan, Kate", "Roebuck, Daniel", "Malahide, Patrick", "Richardson, LaTanya", "Wood, Tom", "Kosik, Thomas", "Stellate, Nick", "Minkoff, Robert", "Brown, Spitfire", "Foster, Reese", "Spielbauer, Bruce", "Mukherji, Kevin", "Cray, Ed", "Fordham, David", "Jett, Charlie"], 
"title": "U.S. Marshals" 
} { 
"index": { 
    "_index": "movies", 
    "_type": "listings", 
    "_id": "4" 
} 
} { 
"director": "Ray, Nicholas", 
"genre": ["Drama", "Romance"], 
"year": 1955, 
"actor": ["Hopper, Dennis", "Wood, Natalie", "Dean, James", "Mineo, Sal", "Backus, Jim", "Platt, Edward", "Ray, Nicholas", "Hopper, William", "Allen, Corey", "Birch, Paul", "Hudson, Rochelle", "Doran, Ann", "Hicks, Chuck", "Leigh, Nelson", "Williams, Robert", "Wessel, Dick", "Bryar, Paul", "Sessions, Almira", "McMahon, David", "Peters Jr., House"], 
"title": "Rebel Without a Cause" 
} 

當我使用這個命令後:

curl -XGET 'search-movies-4f3nw7eiia2xiynjr55a2nao2y.us-west-1.es.amazonaws.com/movies/_search?q=Frankenheimer' 

我從來沒有得到任何回報。總是返回0。這裏是我得到的結果:

enter image description here

我不是,如果我這樣做是正確的,但我想我應該能看到至少有一些事情,因爲我在導演鍵有弗蘭肯海默json數據上傳。任何人都可以闡明它嗎?

+0

你剛剛做了一個捲曲-XGET search-movies-4f3nw7eiia2xiynjr55a2nao2y.us-west-1.es.amazonaws.com/ movies/_search'嗎?這應確保數據實際上位於索引 –

+0

@JohnVeldboom Intresting。我從來沒有嘗試過。是的,我明白了。那麼爲什麼我在添加搜索查詢時沒有收到? –

+0

@JohnVeldboom下面是我嘗試你的時候得到的結果:「1」,「timed_out」:false,「_ shards」:{「total」:5,「success」:5,「failed」:0},「hits 「:{」 總 「:1,」 MAX_SCORE 「:1.0,」 命中 「:[{」 _索引 「:」 電影」, 「_類型」: 「電影」, 「_ ID」: 「1」, 「_分數」:1.0 ,「_源」:{「導演」:「伯頓,蒂姆」,「流派」:[「喜劇」,「科幻」],「年份」:1996年,「演員」:[「傑克尼科爾森」,「皮爾斯Brosnan「,」Sarah Jessica Parker「],」title「:」火星攻擊!「}}]}} –

回答

1

嘗試使用curl -XGET search-movies-4f3nw7eiia2xiynjr55a2nao2y.us-west-1.es.amazon‌​aws.com/movies/_sear‌​ch搜索整個索引,默認返回前10個結果。如果返回小於10,則數據可能不在索引中。

curl -XGET search-movies-4f3nw7eiia2xiynjr55a2nao2y.us-west-1.es.amazon‌​aws.com/movies/_sear‌​ch?q=director:Burton 

退房的Elasticsearch URI Search的參數的完整列表:

您可以通過更改查詢來驗證。

+0

感謝你是對的如果我有一些列已經在mysql的問題,我應該抓住列數據我想添加搜索和插入tehm它使用上面的彈性搜索? –

+1

是的,這是正確的。我以前使用Elasticsearch - 工作得很好,你只需要某種工作,將數據索引到ES。建議:1)使用MySQL中最後一次更新的字段,這將允許您只重新索引已更改的數據。2)使用記錄的唯一標識MySQL作爲ES ID。這將允許您在ES中輕鬆更新記錄。如果你需要更多的幫助,請隨時在Twitter上打我@jveldboom –

+0

謝謝所以如果我沒有錯誤,我可能需要使用logstash或者可能是kenisis + lamda來遷移mysql db中的所有數據,而且我也需要在插入到MySQL數據庫的同時將發送到mysql db的所有新數據發佈到彈性搜索。對嗎?第二步看起來不錯嗎? –