Elasticsearch 查询权重(qbit)

提升字段的权重

multi_match

  • 默认 type 为 best_fields
GET /_search
{
  "query": {
    "multi_match": {
      "query": "this is a test",
      "fields": ["subject^3", "message"]
    }
  }
}
  • most_fields
GET /_search
{
  "query": {
    "multi_match": {
      "query": "this is a test",
      "type": "most_fields",
      "fields": ["subject^3", "message"]
    }
  }
}
// 等价于
GET /_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": { "subject": { "query": "this is a test", "boost": 3 }}
        },
        {
          "macth": { "message": "this is a test" }
        }
      ]
    }
  }
}

query_string

GET /_search
{
  "query": {
    "query_string": {
      "fields": ["content", "name^5"],
      "query": "this AND that OR thus"
    }
  }
}

simple_query_string

GET /_search
{
  "query": {
    "simple_query_string": {
      "query": """"fried eggs" +(eggplant | potato) -frittata""",
      "fields": ["title^5", "body"],
      "default_operator": "and"
    }
  }
}

提升子句的权重

GET /_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": { "subject": { "query": "this is a test", "boost": 3 }}
        },
        {
          "macth": { "message": "this is a test" }
        }
      ]
    }
  }
}

提升索引的权重

GET /_search
{
    "indices_boost" : [
        { "alias1" : 1.4 },
        { "index*" : 1.3 }
    ]
}
本文出自 qbit snap

你可能感兴趣的:(elasticsearch,boost)