Created
June 17, 2014 15:09
-
-
Save ise/d0afdcb43dc02338a0ad to your computer and use it in GitHub Desktop.
elasticsearchのmapping設定方法の検証
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 0.90.3でmapping定義 | |
| # | |
| $ elasticsearch -v | |
| Version: 0.90.3, ... | |
| # jsonのpropertiesの親のkeyをhogeにしてみる | |
| $ cat article.json | |
| { | |
| hoge : { | |
| properties : { | |
| article_id : { | |
| type : "string", | |
| index : "not_analyzed" | |
| }, | |
| title : { | |
| type : "string" | |
| } | |
| } | |
| } | |
| } | |
| # test1というindexに、articleというtypeを定義 | |
| $ curl -XPUT 'http://localhost:9200/test1/article/_mapping' -d '@article.json' | |
| {"ok":true,"acknowledged":true} | |
| # 定義できてるっぽい | |
| $ curl -XGET 'http://localhost:9200/test1/article/_mapping' | |
| { | |
| "article":{ | |
| "article_id":{ | |
| "type":"string", | |
| "index":"not_analyzed", | |
| "omit_norms":true, | |
| "index_options":"docs" | |
| }, | |
| "title":{ | |
| "type":"string" | |
| } | |
| } | |
| } | |
| # | |
| # 1.0.0でmapping定義 | |
| # | |
| $ elasticsearch -v | |
| Version: 1.0.0, ... | |
| # jsonのpropertiesの親のkeyはhoge | |
| $ cat article.json | |
| { | |
| hoge : { | |
| properties : { | |
| article_id : { | |
| type : "string", | |
| index : "not_analyzed" | |
| }, | |
| title : { | |
| type : "string" | |
| } | |
| } | |
| } | |
| } | |
| # test1というindexに、articleというtypeを定義 | |
| $ curl -XPUT 'http://localhost:9200/test1/article/_mapping' -d '@article.json' | |
| {"ok":true,"acknowledged":true} | |
| # 定義できてない。。 | |
| $ curl -XGET 'http://localhost:9200/test1/article/_mapping' | |
| { | |
| "test1":{ | |
| "mappings":{ | |
| "article":{ | |
| "properties":{} | |
| } | |
| } | |
| } | |
| } | |
| # 結論 | |
| # mapping定義のjsonのkey名はtype名と合わせましょう | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment