[ES from entry to actual combat] 16. Full-text search-ElasticSearch-advanced-term query

Continue from section 15

8)、term

Same as match. Match the value of an attribute. 全文检索字段用 match,其他非 text 字段匹配用 term.

Avoid using the term query for text fields.

By default, Elasticsearch changes the values of text fields as part of analysis. This can make finding exact matches for text field values difficult.

To search text field values, use the match query instead.

Non-text values ​​are retrieved using term:

GET /bank/_search
{
    
    
  "query": {
    
    
    "term": {
    
    
      "age":28
    }
  }
}

Insert picture description here

match xxx.keyword, search for exact match of text:

GET /bank/_search
{
    
    
  "query": {
    
    
    "match": {
    
    
      "address.keyword": "789 Madison"
    }
  }
}

Insert picture description here

match Full text word segmentation matching:

GET /bank/_search
{
    
    
  "query": {
    
    
    "match": {
    
    
      "address": "789 Madison"
    }
  }
}

Insert picture description here

match_phrase, to retrieve the value to be matched as a whole word (no word segmentation):

GET /bank/_search
{
    
    
  "query": {
    
    
    "match_phrase": {
    
    
      "address": "789 Madison"
    }
  }
}

Insert picture description here

注意: If you use term to search for text values, the word segmentation will not be performed, but the exact search will be performed, so the data may not be matched:

GET /bank/_search
{
    
    
  "query": {
    
    
    "term": {
    
    
      "address": "789 Madison"
    }
  }
}

Insert picture description here

Reference document-query-dsl-term-query

Reference document-query-dsl


reference:

Elasticsearch Reference

elastic

Getting started with the full-text search engine Elasticsearch

Guess you like

Origin blog.csdn.net/runewbie/article/details/106366284