ElasticSearch最佳入門實踐(三十七)用一個例子告訴你 mapping 到底是什麼
阿新 • • 發佈:2018-11-07
1、插入幾條資料
PUT /website/article/1 { "post_date": "2017-01-01", "title": "my first article", "content": "this is my first article in this website", "author_id": 11400 } PUT /website/article/2 { "post_date": "2017-01-02", "title": "my second article", "content": "this is my second article in this website", "author_id": 11400 } PUT /website/article/3 { "post_date": "2017-01-03", "title": "my third article", "content": "this is my third article in this website", "author_id": 11400 }
2、各種搜尋
3、檢視es自動建立的mapping
自動或手動為index中的type建立的一種資料結構和相關配置,簡稱為mapping
dynamic mapping,自動為我們建立index,建立type,以及type對應的mapping,mapping中包含了每個field對應的資料型別,以及如何分詞等設定,也可以手動在建立資料之前,先建立index和type,以及type對應的mapping
搜尋結果為什麼不一致,因為es自動建立mapping的時候,設定了不同的field不同的data type。不同的data type的分詞、搜尋等行為是不一樣的。所以出現了_all field和post_date field的搜尋表現完全不一樣。