2 Match, Filter, sorting, paging, full-text search, phrase match keywords highlighted

All documentation within search index
GET  /beauties/my/_search
 
GET  /beauties/my/_search
{
    "query":{
        "match_all": {}
    }
}
Matching, sorting
GET  /beauties/my/_search
{
    "query": {
        "match": {
           "Name": "Ruru"
        }
    },
    "sort": [
       {"Age": "desc"}
    ]
}
Filter Fields
GET  /beauties/my/_search
{
    "query": {
        "match_all": {}
    },
    "_source":["Name","Age"]
}
Paging
GET  /beauties/my/_search
{
    "query": {
        "match_all": {}
    },
    "_source":["Name","Age"],
    "from": 1,
    "size": 2
}
bool filter、
GET   /beauties/my/_search
{
    "query": {
        "bool": {
            "must": {
               "match": {
                  "Name": "Zhao"
               }
           },
           "filter":{
               "range": {
                  "Age": {
                     "gt": 19,
                     "lt":24
                  }
               }
           }
        }
    }
}
GET  /beauties/my/5
POST  /beauties/my/5/_update
{
    "doc":{
        "Desc":"Ruru Friend"
    }    
}
 
 
Full Text Search: will match Name, contains the following words, as long as the match will be able to search out a word, but the score is not the same
GET  /beauties/my/_search
{
    "query": {
        "match": {
           "Name": "Zhao Ruru Chang Aijing Wei"
        }
    }
}
 
Search phrase: Zhao Ruru must match the job.
Name = Zhao Ruru the recording, the search can search out match_phrase = Zhao, = Zha found out
GET  /beauties/my/_search
{
    "query": {
        "match_phrase": {
           "Name": "Zhao Ruru"
        }
    }
}
Highlight matching keywords. It will be in the results, to add keyword tags em
GET  /beauties/my/_search
{
    "query": {
        "match_phrase": {
           "Name": "Zhao"
        }
    },
    "highlight": {
        "fields": {
            "Name":{}
        }
    }
}
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/cc299/p/11032796.html