1、角色关系对照
elasticsearch 跟 MySQL 中定义资料格式的角色关系对照表如下
$ curl -XPUT http://localhost:9200/test-index test-index为库名。
$ curl -XPUT http://10.1.11.183:9200/test-index/test-type/_mapping -d'{
"properties" : {
"name" : { "type" : "string" }
}
}'
mapping ={
u'id': {'store': 'yes',
'type': u'integer'},
u'author': {'boost': 1.0,
'index': 'not_analyzed',
'store': 'yes',
'type': u'string'},
u'published': {'boost': 1.0,
'index': 'not_analyzed',
'store': 'yes',
'type': u'datetime'},
u'url': {'store': 'yes',
'type': u'string'},
u'title': {'boost': 1.0,
'index': 'analyzed',
'store': 'yes',
'type': u'string'},
u'content': {'boost': 1.0,
'index': 'analyzed',
'store': 'yes',
'type': u'string',
"term_vector" : "with_positions_offsets"}
}
$ curl -XPUT http://localhost:9200/test-index/test-type/1-d'{
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?"
$ curl -XGET http://localhost:9200/test-index/test-type/1
$ curl -XDELETE'http://localhost:9200/test-index/test-type/1'
$ curl -XGET http://localhost:9200/test-index/test-type/q=user:_search?kimchy
$ curl -XGET http://localhost:9200/test-index/test-type/_search -d'{
"query" : {
"term" : { "user": "kimchy" }
}
}'
$ curl -XGET http://localhost:9200/test-index/_search?pretty=true-d'{
"query" : {
"range" : {
"post_date" : {
"from" : "2009-11-15T13:00:00",
"to" : "2009-11-15T14:30:00"
}
}
}
}'
$ curl -XGET http://localhost:9200/test-index/test-type/_search?pretty=true