POST /_analyze
{}
PUT /my_index/_doc/1
{
"id":1,
"title":"es简介",
"description": "catelina cat",
"content":"es好用好用gg真好用",
"age": 20,
"price": 70,
"gender":"M"
}
PUT /my_index/_doc/2
{
"id":2,
"title":"java编程思想",
"description": "javacatmorning dog",
"content":"这就是个工具书",
"age": 30,
"price": 80,
"gender":"M"
}
PUT /my_index/_doc/3
{
"id":3,
"title":"大数据简介",
"description": "bigdatacatnight tiger",
"content":"你知道什么是大数据吗,就是大数据",
"age": 40,
"price": 41,
"gender":"F"
}
PUT /my_index/_doc/4
{
"id":4,
"title":"大数据简介",
"description": "bigdatacatnight tiger",
"content":"你知道什么是大数据吗,就是大数据",
"age": 50,
"price": 41,
"gender":"F"
}
GET /my_index/_search
{
"query": {
"match_all": {}
}
}
GET /my_index/_search
{
"query":{
"term":{
"title": "简"
}
}
}
GET /my_index/_search
{
"query":{
"terms":{
"title": ["es", "java"]
}
}
}
GET /my_index/_search
{
"query": {
"match": {
"title": "简介"
}
},
"sort": [
{
"_id": {
"order": "desc"
}
}
]
}
GET /my_index/_search
{
"query": {
"multi_match": {
"query": "数据 思想",
"fields": [
"title",
"content"
],
"operator": "OR"
}
}
}
GET /my_index/_search
{
"query":{
"bool":{
"must":[{
"term":{
"title": "es"
}
},{
"term":{
"content": "gg"
}
}
],
"should": [
{"term":{"age":20}},
{"term":{"age":30}}
],
"filter": {
"range": {
"create_admin_id": {
"gte": 10,
"lte": 20
}
}
}
}
}
}
GET /my_index/_search
{
"query":{
"range":{
"age":{
"gte": 20,
"lte": 30
}
}
}
}
GET /my_index/_search
{
"query":{
"wildcard":{
"description": "*cat*"
}
}
}
GET /my_index/_search
{
"query":{
"regexp":{
"description":{
"value":".*cat.*",
"boost":10.0
}
}
}
}
GET /my_index/_search
{
"query":{
"match_phrase_prefix":{
"description":{
"query":"java",
"slop":10.0
}
}
}
}
GET /my_index/_search
{
"query":{
"query_string":{
"query": "cat dog"
}
}
}
GET /my_index/_search
{
"aggs":{
"avg_ages":{
"avg":{
"field":"age"
}
}
}
}
GET /my_index/_search
{
"size": 0,
"aggs": {
"agg_terms": {
"terms": {
"field": "price",
"order": {
"_count": "asc"
}
},
"aggs": {
"max_age": {
"max": {
"field": "age"
}
}
}
}
}
}
GET /my_index/_search
{
"size": 0,
"aggs": {
"agg_terms": {
"terms": {
"field": "price",
"order": {
"_count": "asc"
}
},
"aggs": {
"max_age": {
"max": {
"field": "age"
}
}
}
}
}
}