ElasticSearch教程——mapping详解

本文详细介绍了ElasticSearch的mapping概念,包括动态mapping、_all元数据的工作原理,以及核心数据类型。通过实例展示了如何手动创建mapping,并测试了不同analyzer和数据类型的效果,强调了mapping对搜索行为的影响。
摘要由CSDN通过智能技术生成

ElasticSearch汇总请查看:ElasticSearch教程——汇总篇

 

前期准备

插入几条数据,让es自动为我们建立一个索引

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
}

尝试各种搜索

GET /website/article/_search?q=2017                                3条结果             
GET /website/article/_search?q=2017-01-01                      3条结果
GET /website/article/_search?q=post_date:2017-01-01     1条结果
GET /website/article/_search?q=post_date:2017                1条结果

 

 

初识mapping

通过如下请求可以查看自动建立的mapping中的数据类型,从而带出什么是mapping的知识点

GET /website/_mapping/article

返回结果

{
  "website": {
    "mappings": {
      "article": {
        "properties": {
      
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东天里的冬天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值