elasticsearch创建索引 ,mapping,dynamic_templates

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: elasticsearch 创建索引时通常需要配置mapping。mapping的含义类似于关系数据库中的表结构。但mapping更加灵活。

简述

elasticsearch 创建索引时通常需要配置mapping。mapping的含义类似于关系数据库中的表结构。但mapping更加灵活。

创建

以下实例是创建索引:my-index-000001,并加入dynamic_templates。
地址
http://localhost:9400/my-index-000001
方式
put
端口
http 端口
模板内容

{
  "mappings": {
    "_default_": {
     "dynamic_templates": [
          {
            "string_fields": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "analyzer": "ik_max_word",
                "fields": {
                  "raw": {
                    "ignore_above": 2000,
                    "type": "keyword"
                  }
                },
                "index": "true",
                "omit_norms": true,
                "type": "text"
              }
            }
          }
        ],
          "properties": {
                    "amount": {
                        "type": "double"
                       
                    }
          }
    }
  }
}

curl 方式

curl --location --request PUT 'http://localhost:9400/my-index-000001' \
--header 'Content-Type: application/json' \
--data-raw '{
  "mappings": {
    "_default_": {
     "dynamic_templates": [
          {
            "string_fields": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "analyzer": "ik_max_word",
                "fields": {
                  "raw": {
                    "ignore_above": 2000,
                    "type": "keyword"
                  }
                },
                "index": "true",
                "omit_norms": true,
                "type": "text"
              }
            }
          }
        ],
          "properties": {
                    "contract_amount": {
                        "type": "double"
                        
                    }
          }
    }
  }
}'

总结

上面的模板中配置了 amountdouble 类型。分词器:ik_max_word,查询不分词的属性:raw

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
12天前
|
自然语言处理 大数据 应用服务中间件
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
41 5
|
12天前
|
存储 分布式计算 大数据
大数据-169 Elasticsearch 索引使用 与 架构概念 增删改查
大数据-169 Elasticsearch 索引使用 与 架构概念 增删改查
47 3
|
2月前
|
存储 API 数据库
检索服务elasticsearch索引(Index)
【8月更文挑战第23天】
57 6
|
1月前
|
JSON 自然语言处理 数据库
ElasticSearch基础1——索引和文档。Kibana,RestClient操作索引和文档+黑马旅游ES库导入
概念、ik分词器、倒排索引、索引和文档的增删改查、RestClient对索引和文档的增删改查
ElasticSearch基础1——索引和文档。Kibana,RestClient操作索引和文档+黑马旅游ES库导入
|
1月前
|
存储 搜索推荐 数据建模
Elasticsearch 的数据建模与索引设计
【9月更文第3天】Elasticsearch 是一个基于 Lucene 的搜索引擎,广泛应用于全文检索、数据分析等领域。为了确保 Elasticsearch 的高效运行,合理的数据建模和索引设计至关重要。本文将探讨如何为不同的应用场景设计高效的索引结构,并分享一些数据建模的最佳实践。
84 2
|
2月前
|
存储 运维 搜索推荐
运维开发.索引引擎ElasticSearch.倒序索引的概念
运维开发.索引引擎ElasticSearch.倒序索引的概念
48 1
|
2月前
|
JSON 自然语言处理 数据库
Elasticsearch从入门到项目部署 安装 分词器 索引库操作
这篇文章详细介绍了Elasticsearch的基本概念、倒排索引原理、安装部署、IK分词器的使用,以及如何在Elasticsearch中进行索引库的CRUD操作,旨在帮助读者从入门到项目部署全面掌握Elasticsearch的使用。
|
2月前
|
自然语言处理 Java 索引
ElasticSearch 实现分词全文检索 - Java SpringBoot ES 索引操作
ElasticSearch 实现分词全文检索 - Java SpringBoot ES 索引操作
37 0
|
2月前
|
运维 安全 网络协议
运维.索引引擎ElasticSearch.记录一个小异常:received plaintext http traffic on an https channel
运维.索引引擎ElasticSearch.记录一个小异常:received plaintext http traffic on an https channel
200 0
|
3月前
|
存储 SQL 自然语言处理
Elasticsearch 索引与文档的常用操作总结二:复杂条件查询
Elasticsearch 索引与文档的常用操作总结二:复杂条件查询
135 0