Giter Site home page Giter Site logo

gspandy / elasticsearch-mapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gitchennan/elasticsearch-mapper

0.0 1.0 0.0 113 KB

一款基于Java注解的elasticsearch mapping生成工具,支持ES 5.2.0所有可选参数

License: Apache License 2.0

Java 100.00%

elasticsearch-mapper's Introduction

#elasticsearch-mapper

org.elasticsearch.mapper.test.MappingTest


@Document(_type = "macBook", _all = @MetaField_All(enabled = false), _parent = @MetaField_Parent(parentClass = Computer.class))
public class MacBook extends Component {

    // default: keyword
    private String deviceName;

    @StringField(type = StringType.Text)
    private String manufacturer;

    @MultiField(
            mainField = @StringField(type = StringType.Keyword, boost = 2.0f),
            fields = {
                    @MultiNestedField(name = "pinyin", field = @StringField(type = StringType.Text, analyzer = "lc_pinyin")),
                    @MultiNestedField(name = "cn", field = @StringField(type = StringType.Text, analyzer = "ik_smart")),
                    @MultiNestedField(name = "en", field = @StringField(type = StringType.Text, analyzer = "english")),
            },
            tokenFields = {
                    @TokenCountField(name = "cnTokenCount", analyzer = "ik_smart")
            }
    )
    private String introduction;

    // nested doc
    private List<User> users;

    // inner doc
    private Cpu cpu;

    //inner doc
    private Memory memory;
}

public class Component {

    private String serialNo;

    private String madeIn;
}

@Document(_type = "computer")
public class Computer {
    private String parentField;
}


public class User {

    private boolean isRoot;

    private String username;

    private String password;
}

public class Cpu extends Component {
    private int coreNumber;
}


public class Memory extends Component {
    @NumberField(type = NumberType.Byte)
    private Byte memorySize;
}

{
  "computer" : {
    "properties" : {
      "parentField" : {
        "type" : "keyword"
      }
    }
  }
}


{
  "macBook" : {
    "_all" : {
      "enabled" : false
    },
    "_parent" : {
      "type" : "computer"
    },
    "properties" : {
      "deviceName" : {
        "type" : "keyword"
      },
      "manufacturer" : {
        "type" : "text"
      },
      "introduction" : {
        "type" : "keyword",
        "boost" : 2.0,
        "fields" : {
          "pinyin" : {
            "type" : "text",
            "analyzer" : "lc_pinyin"
          },
          "cn" : {
            "type" : "text",
            "analyzer" : "ik_smart"
          },
          "en" : {
            "type" : "text",
            "analyzer" : "english"
          },
          "cnTokenCount" : {
            "type" : "token_count",
            "analyzer" : "ik_smart"
          }
        }
      },
      "users" : {
        "type" : "nested",
        "properties" : {
          "isRoot" : {
            "type" : "boolean"
          },
          "username" : {
            "type" : "keyword"
          },
          "password" : {
            "type" : "keyword"
          }
        }
      },
      "cpu" : {
        "type" : "object",
        "properties" : {
          "coreNumber" : {
            "type" : "integer"
          },
          "serialNo" : {
            "type" : "keyword"
          },
          "madeIn" : {
            "type" : "keyword"
          }
        }
      },
      "memory" : {
        "type" : "object",
        "properties" : {
          "memorySize" : {
            "type" : "byte"
          },
          "serialNo" : {
            "type" : "keyword"
          },
          "madeIn" : {
            "type" : "keyword"
          }
        }
      },
      "serialNo" : {
        "type" : "keyword"
      },
      "madeIn" : {
        "type" : "keyword"
      }
    }
  }
}

elasticsearch-mapper's People

Contributors

gitchennan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.