Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/es.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/es.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
邮编与结构化数据 | Elasticsearch: 权威指南 | Elastic - 互联网笔记

略微加速

Elasticsearch权威指南 - 互联网笔记

邮编与结构化数据 | Elasticsearch: 权威指南 | Elastic

2025-04-18

邮编与结构化数据编辑

我们会使用美国目前使用的邮编形式(United Kingdom postcodes 标准)来说明如何用部分匹配查询结构化数据。 这种邮编形式有很好的结构定义。例如,邮编 W1V 3DG 可以分解成如下形式:

  • W1V :这是邮编的外部,它定义了邮件的区域和行政区:

    • W 代表区域( 1 或 2 个字母)
    • 1V 代表行政区( 1 或 2 个数字,可能跟着一个字符)
  • 3DG :内部定义了街道或建筑:

    • 3 代表街区区块( 1 个数字)
    • DG 代表单元( 2 个字母)

假设将邮编作为 not_analyzed 的精确值字段索引,所以可以为其创建索引,如下:

PUT /my_index
{
    "mappings": {
        "address": {
            "properties": {
                "postcode": {
                    "type":  "string",
                    "index": "not_analyzed"
                }
            }
        }
    }
}

然后索引一些邮编:

PUT /my_index/address/1
{ "postcode": "W1V 3DG" }

PUT /my_index/address/2
{ "postcode": "W2F 8HW" }

PUT /my_index/address/3
{ "postcode": "W1F 7HW" }

PUT /my_index/address/4
{ "postcode": "WC1N 1LZ" }

PUT /my_index/address/5
{ "postcode": "SW5 0BE" }

现在这些数据已可查询。

官方地址:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_postcodes_and_structured_data.html

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3