weixin_44514323 2021-04-15 14:22 采纳率: 28.6%
浏览 24
已采纳

elasticsearch入门的语法问题

语法1.

PUT /索引库名/_mapping/类型名称
{
  "properties": {
    "字段名": {
      "type": "类型",
      "index": true,
      "store": true,
      "analyzer": "分词器"
    }
  }
}

语法2. 

PUT /索引库名
{
  
  "mappings": {
    类型名称: {
      "properties": {
           字段
      }
    }
  }
}

语法1和语法2是一个意思吗?

语法3:

POST /cars/transactions/_bulk
{ "index": {}}
{ "price" : 10000, "color" : "red", "make" : "honda", "sold" : "2014-10-28" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 30000, "color" : "green", "make" : "ford", "sold" : "2014-05-18" }
{ "index": {}}
{ "price" : 15000, "color" : "blue", "make" : "toyota", "sold" : "2014-07-02" }
{ "index": {}}
{ "price" : 12000, "color" : "green", "make" : "toyota", "sold" : "2014-08-19" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 80000, "color" : "red", "make" : "bmw", "sold" : "2014-01-01" }
{ "index": {}}
{ "price" : 25000, "color" : "blue", "make" : "ford", "sold" : "2014-02-12" }

我知道语法3是批量提交,但是我发现每一个提交的row的上面都有{ "index": {}}这样的数据结构,它是为了设置什么吗?

  • 写回答

1条回答 默认 最新

  • 张小帅和刘美美 2021-04-15 14:34
    关注

    语法1和语法2是一个意思
    语法就是这样
    POST example/docs/_bulk
    {"index": {"_id": 1}}
    {"id":1, "name": "admin", "counter":"10", "tags":["red", "black"]}
    {"index": {"_id": 2}}
    {"id":2, "name": "张三", "counter":"20", "tags":["green", "purple"]}
    {"index": {"_id": 3}}
    {"id":3, "name": "李四", "counter":"30", "tags":["red", "blue"]}
    {"index": {"_id": 4}}
    {"id":4, "name": "tom", "counter":"40", "tags":["orange"]}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题