PUT /heima
{
"settings": {
"number_of_shards": 1
, "number_of_replicas": 0
}
}
GET /heima1
DELETE /heima1
PUT heima/_mapping/goods
{
"properties": {
"title": {
"type": "text",
"analyzer": "ik_max_word"
},
"images": {
"type": "keyword",
"index": "false"
},
"price": {
"type": "float"
}
}
}
GET /heima/_mapping
POST /heima/goods/3
{
"title":"超米手机",
"images":"http://image.leyou.com/12479122.jpg",
"price":3699.00,
"saleable": true
}
PUT /heima/goods/4
{
"title":"小米电视4A",
"images":"http://image.leyou.com/12479122.jpg",
"price":3899.00
}
PUT /heima/goods/5
{
"title":"华为手机",
"subTitle": "小米",
"images":"http://image.leyou.com/12479122.jpg",
"price":3999.00
}
GET /heima/_search
{
"query":{
"match_all":{}
}
}
DELETE /heima/goods/NGGgXm4B1XJkxRhg9ed4
GET /heima/_search
{
"query": {
"match": {
"title": {
"query": "小米手机电视",
"minimum_should_match": "30%"
}
}
}
}
GET /heima/_search
{
"query": {
"multi_match": {
"query": "小米",
"fields": ["title","subTitle"]
}
}
}
GET /heima/_search
{
"query": {
"term": {
"title": {
"value": "小米"
}
}
}
}
GET /heima/_search
{
"_source": ["title", "price"],
"query": {
"terms": {
"title": [
"小米",
"华为"
]
}
}
}
GET /heima/_search
{
"_source": {
"excludes": "images"
},
"query": {
"terms": {
"title": [
"小米",
"华为"
]
}
}
}
GET /heima/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "小米"
}
},
{
"terms": {
"price": [
"2799",
"2699"
]
}
}
]
}
}
}
GET /heima/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": "小米"
}
},
{
"terms": {
"price": [
"2799",
"2699"
]
}
}
]
}
}
}
GET /heima/_search
{
"query": {
"range": {
"price": {
"gte": 2699,
"lte": 3899
}
}
}
}