【Elasticsearch】Mapping APIs

本文详细介绍了Elasticsearch中的字段数据类型及元字段的功能,并解释了如何使用多字段映射来针对不同目的对同一字段进行多种方式的索引,例如全文搜索和排序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html

一、Field datatypes:

二、Meta-Fields:




_indexThe index to which the document belongs
_uidA composite field consisting of the _type and the _id
_typeThe document's mapping type
_idThe document's id



_sourceThe original JSON representing the body of the document
_sizeThe size of the _source field in bytes,provided by the mapper-size plugin



_allA catch-all field that indexes the values of all other fields
_field_names

_timestamp

_ttl




_parentUsed to create a parent-child relationship between two mapping types
_routingA custom routing value which routes a document to a particular shard



_metaApplicationg specific metadata


三、Mapping parameters

fields:

It is often useful to Index the same filed in different ways for different purposes.This is the purpose of multi-fileds.For instance,a string field could be indexed as an analyzed field for full-text search, and as a not_analyzed field for sorting or aggregations

curl -XPUT 'http://localhost:9200/my_index/_mapping/my_type' -d '{
  "properties": {
    "city": {
      "type": "string",
      "fields": {
        "raw": {                    =>city.raw field is a not_analyzed version of city field
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
  }
}'

curl -XPUT 'http://localhost:9200/my_index//my_type/1' -d '{
    "city":"New York"
}'

curl -XPUT 'http://localhost:9200/my_index//my_type/2' -d '{
    "city":"York"
}'

curl -XGET 'http://10.224.246.146:9200/my_index/my_type/_search'


转载于:https://my.oschina.net/u/204498/blog/656726

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值