es 记录

1,创建索引库
        curl -XPUT 'http://10.0.0.176:9200/xiu'
             结果 {"acknowledged":true}You have new mail in /var/spool/mail/root

        curl -XPOST 'http://10.0.0.176:9200/xiu1'

2,创建索引
        curl -XPUT 'http://10.0.0.176:9200/xiu1/onsale'
        RESTful接口URL的格式:http://localhost:9200/<index>/<type>/[<id>]
        其中index、type是必须提供的。
        id是可选的,不提供es会自动生成。
3,查看mapping
       curl -XGET "http://10.0.0.176:9200/xiu1/_mapping?pretty"
4,创建索引product
 curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '
{
    "product": {
            "properties": {
                "title": {
                    "type": "string",
                    "store": "yes"
                },
                "description": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "price": {
                    "type": "double"
                },
                "onSale": {
                    "type": "boolean"
                },
                "type": {
                    "type": "integer"
                },
                "createDate": {
                    "type": "date"
                }
            }
        }
  }'
 
5,新增mapping 字段
curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '{
     "product": {
                "properties": {
                     "amount":{
                        "type":"integer"
                   }
                }
            }
    }’
6,修改mapping 字段类型
curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '{
     "product": {
                "properties": {
                 "onSale":{
                    "type":"string"
               }
            }
        }

}',

7,添加数据

curl -XPOST http://10.0.0.176:9200/xiu1/product/ -d '{"description":"elasticsearch添加索引数据"}'
curl -XPOST http://10.0.0.176:9200/xiu1/product/ -d '{"amount":20000,"description":"elasticsearch添加索引数据","title":"中华人民","type":100}'

8,索引查询 格式化

curl -XGET 'http://10.0.0.176:9200/xiu1/product/AV1VlZNJUuvIr5lrbiVh/?pretty'

9,查询索引 返回指定字段

curl -XGET 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi/?_source=amount,title&pretty'

10,查看某个索引所有数据

curl -XGET 'http://10.0.0.176:9200/xiu1/product/_search?pretty'

11,更新索引

curl -XPOST 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi/_update' -d '{"doc":{"title":"中华共和国"}}'

ES全部更新,使用PUT或者POST
ES局部更新,使用POST

12,删除索引

curl -XDELETE 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi'

13,添加ik分词

   在elasticsearch-5.4.0/plugins下添加文件夹 elasticsearch-analysis-ik-5.4.0

14,创建索引 curl -XPUT "http://localhost:9200/testb"

        curl -XGET "http://localhost:9200/testb/_analyze?analyzer=ik_max_word" -H 'Content-Type: application/json' -d'
          {
               "text": "女士牛皮金属装饰芭蕾舞鞋"
          }'

         结果:{
  "tokens": [
    {
      "token": "女士",
      "start_offset": 0,
      "end_offset": 2,
      "type": "CN_WORD",
      "position": 0
    },
    {
      "token": "牛皮",
      "start_offset": 2,
      "end_offset": 4,
      "type": "CN_WORD",
      "position": 1
    },
    {
      "token": "牛",
      "start_offset": 2,
      "end_offset": 3,
      "type": "CN_WORD",
      "position": 2
    },
    {
      "token": "皮",
      "start_offset": 3,
      "end_offset": 4,
      "type": "CN_WORD",
      "position": 3
    },
    {
      "token": "金属",
      "start_offset": 4,
      "end_offset": 6,
      "type": "CN_WORD",
      "position": 4
    },
    {
      "token": "装饰",
      "start_offset": 6,
      "end_offset": 8,
      "type": "CN_WORD",
      "position": 5
    },
    {
      "token": "饰",
      "start_offset": 7,
      "end_offset": 8,
      "type": "CN_WORD",
      "position": 6
    },
    {
      "token": "芭蕾舞鞋",
      "start_offset": 8,
      "end_offset": 12,
      "type": "CN_WORD",
      "position": 7
    },
    {
      "token": "芭蕾舞",
      "start_offset": 8,
      "end_offset": 11,
      "type": "CN_WORD",
      "position": 8
    },
    {
      "token": "芭蕾",
      "start_offset": 8,
      "end_offset": 10,
      "type": "CN_WORD",
      "position": 9
    },
    {
      "token": "芭",
      "start_offset": 8,
      "end_offset": 9,
      "type": "CN_WORD",
      "position": 10
    },
    {
      "token": "蕾",
      "start_offset": 9,
      "end_offset": 10,
      "type": "CN_WORD",
      "position": 11
    },
    {
      "token": "舞鞋",
      "start_offset": 10,
      "end_offset": 12,
      "type": "CN_WORD",
      "position": 12
    },
    {
      "token": "鞋",
      "start_offset": 11,
      "end_offset": 12,
      "type": "CN_WORD",
      "position": 13
    }
  ]
}

          

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值