ES-mapping article

Command GET index / type / _mapping a view mapping index

Personally I like to write a mapping file separately, instead of notes written on the bean properties

For example, create a new Product of the bean object can write:

1.

@Document(indexName = "index_product" ,type = “index_product”,shards = 1,replicas =2)

public class Product{

@Id

private String id;

@Field(type = FieldType.Text, analyzer = "ik_max_word")

private String productName;

@Field(index = false, type = FieldType.Keyword)

private String productInfo;

....

}

 

2.

Which can also be written in the mapping, as follows: 

@Mapping(mappingPath="/XXX/XXX/index_product_mapping.json")

@Document(indexName = "index_product" ,type = “index_product”,shards = 1,replicas =2)

public class Product{

@Id

private String id;

@Field(type = FieldType.Text, analyzer "ik_max_word")

private String productName;

@Field(index false, type = FieldType.Keyword)

private String productInfo;

....

}

index_product_mapping.json file

{

  "index_product":{

    "properties":{

      "id":{

        "type":"text"

      }

      “productInfo”:{

        "type":"text",

        "Index": false #index parameter role is to control whether the current field is indexed, the default is true, false representation does not record that can not be searched, 

      }

    }

  }

}

If the index is false, it can not be searched,

GET index_product/index_product/_search { "query": { "match": { "productInfo": "111" } } }  则会报错

 type of data:

Core data types:

String: text, keyword (not word)
Numeric: long, integer, short, byte , double, float, half_float other
date type: date
Boolean: boolean
binary type: binary
range type: integer_range, float_range, long_range, double_range, date_range


Complex data types:

Array types: array
object type: object
nested types: nested object
geographic data types: geo_point, geo_shape
special type: ip (ip address record), completion (automatic completion), token_count (divided recording number of words), murmur3 (recording string hash value

 

Guess you like

Origin www.cnblogs.com/shigwcc/p/11230386.html