我们可以在创建索引时设置mapping信息,也可以先创建索引然后再设置mapping

    一个表下面3个字段,还有每个字段的属性
    article表properties,title,content字段

    1. PUT blog1
    2. {
    3. "mappings": {
    4. "article": {
    5. "properties": {
    6. "id": {
    7. "type": "long",
    8. "store": true
    9. },
    10. "title": {
    11. "type": "text",
    12. "store": true,
    13. "index": true,
    14. "analyzer": "standard"
    15. },
    16. "content": {
    17. "type": "text",
    18. "store": true,
    19. "index": true,
    20. "analyzer": "standard"
    21. }
    22. }
    23. }
    24. }
    25. }

    查看下

    GET /blog1
    
    POST /blog/hello/_mapping
    {
      "hello": {
        "properties": {
          "id": {
            "type": "long",
            "store": true
          },
          "title": {
            "type": "text",
            "store": true,
            "index": true,
            "analyzer": "standard"
          },
          "content": {
            "type": "text",
            "store": true,
            "index": true,
            "analyzer": "standard"
          }
        }
      }
    }