天天看點

Elaticsearch第八篇 Es的映射(表設計)

1、設計 表

put方法 127.0.0.1:9200/index_mapping

{
    "mappings":{
        "properties": {
            "realname":{
                "type":"text",
                "index":true
            },
            "username":{
                "type":"keyword",
                "index":false
            }

        }

    }

}
           

2、_anaylze

get 方法 127.0.0.1:9200/index_mapping/_analyze

{
    "field": "realname",
    "text":"imooc is very good"


}
           

上述是一個一個詞分開。

修改如下,就是一整段了。 keyword 因為

{
    "field": "username",
    "text":"imooc is very good"


}
           

3、增加兩個表的字段設計

post 方法 127.0.0.1:9200/index_mapping/_mapping

{
           "properties": {
            "id":{
                "type":"long",
                "index":true
            },
            "age":{
                "type":"integer",
                "index":false
            }

        }

}
           

四、其他 字段

{
           "properties": {
            "money1":{
                "type":"float"
              
            },
            "money2":{
                "type":"double"
               
            }
            

        }

}
           
{
           "properties": {
            "sex":{
                "type":"byte"
              
            },
            "score":{
                "type":"short"
               
            }
            

        }

}
           
{
    "properties": {
        "is_teenger": {
            "type": "boolean"
        },
        "birthday": {
            "type": "date"
        },
        "relationship": {
            "type": "object"
        }
    }
}