1. 程式人生 > >elasticsearch(5)對映

elasticsearch(5)對映

示例

PUT /secisland
{
  "mappings": {
    "user": {
      "_all": {
        "enabled": false
      }, 
      "properties": {
        "title": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        }
      }
    },
    "blogpost": {
      "properties": {
        "title": {
          "type": "string"
        },
        "body": {
          "type": "string"
        },
        "user_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "create": {
          "type": "date",
          "format": "strict_date_optional_time || epoch_millis"
        }
      }
    }
  }
}

欄位資料型別

elasticsearch支援一下的資料型別

  • 核心資料型別:
    • 字串資料型別: string
    • 數值型資料型別: long,integer,short,byte,double,float
    • 日期型資料型別: date
    • 布林型資料型別: boolean
    • 二進位制資料型別: binary
  • 複雜資料型別:
    • 陣列資料型別: []
    • 物件資料型別: object(單獨的json物件)
    • 巢狀資料型別: nested(關於json物件的陣列)
  • 地理資料型別:
    • 地理點資料型別: geo_point(經緯點)
    • 地理形狀資料型別: geo_shape(多邊形的複雜地理形狀)
  • 專門資料型別:
    • ipv4資料型別: ipv4地址
    • 完成資料型別: completion(提供自動補全的建議)
    • 單詞計數資料型別: token_count(統計字串中的單詞數量)