下载地址 https://www.elastic.co/downloads
下载并解压到 /usr/local/elasticsearch
cd /usr/local/elasticsearch
bin/elasticsearch
下载地址 https://www.elastic.co/downloads
下载并解压到 /usr/local/kibana
cd /usr/local/kibana
bin/kibana
浏览器访问http://localhost:5601 , 可以看的界面,说明配置正确。
创建文件/usr/local/scrapy.course-index-template.json, 内容如下
{
"mappings": {
"_default_": {
"_all": {
"enabled": true,
"norms": {
"enabled": false
}
},
"dynamic_templates": [
{
"strings_as_keywords": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
},
{
"unindexed_longs": {
"match_mapping_type": "long",
"mapping": {
"type": "long",
"index": false
}
}
},
{
"unindexed_doubles": {
"match_mapping_type": "double",
"mapping": {
"type": "float",
"index": false
}
}
},
{
"template1": {
"mapping": {
"doc_values": true,
"ignore_above": 1024,
"index": "not_analyzed",
"type": "{dynamic_type}"
},
"match": "*"
}
}
],
"properties": {
"title": {
"type": "keyword"
},
"subtitle": {
"type": "text",
"index": "analyzed"
},
"url": {
"type": "keyword"
},
"status": {
"type": "keyword"
},
"price": {
"type": "keyword"
},
"rating": {
"type": "integer"
},
"ratingNum": {
"type": "integer"
},
"c_tags": {
"type": "text",
"index": "analyzed"
},
"smallPicture": {
"type": "keyword"
},
"middlePicture": {
"type": "keyword"
},
"largePicture": {
"type": "keyword"
},
"about": {
"type": "text",
"index": "analyzed"
},
"goals": {
"type": "text",
"index": "analyzed"
},
"studentNum": {
"type": "integer"
},
"hitNum": {
"type": "integer"
},
"created": {
"type": "date"
},
"updated": {
"type": "date"
}
}
}
},
"settings": {
"index.refresh_interval": "5s"
},
"template": "scrapy.course"
}
导入template到elasticsearch
cd /usr/local
curl -XPUT 'http://localhost:9200/_template/crapy.course?pretty' -d@scrapy.course-index-template.json
进入kibana : http://localhost:5601, 选择Dev Tools
在右侧,输入以下内容并点击尖头执行
put scrapy.course/normal/1
{
"title":"Think in Java"
}
Dev Tools 右侧输入一下命了,并执行
get scrapy.course/normal/1
执行结果
{
"_index": "scrapy.course",
"_type": "normal",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"title": "Think in Java"
}
}
说明索引创建成功。