Span Term 查询

编辑

匹配包含某个 term 的跨度。以下是一个示例

resp = client.search(
    query={
        "span_term": {
            "user.id": "kimchy"
        }
    },
)
print(resp)
response = client.search(
  body: {
    query: {
      span_term: {
        'user.id' => 'kimchy'
      }
    }
  }
)
puts response
const response = await client.search({
  query: {
    span_term: {
      "user.id": "kimchy",
    },
  },
});
console.log(response);
GET /_search
{
  "query": {
    "span_term" : { "user.id" : "kimchy" }
  }
}

查询还可以关联一个 boost 值

resp = client.search(
    query={
        "span_term": {
            "user.id": {
                "value": "kimchy",
                "boost": 2
            }
        }
    },
)
print(resp)
response = client.search(
  body: {
    query: {
      span_term: {
        'user.id' => {
          value: 'kimchy',
          boost: 2
        }
      }
    }
  }
)
puts response
const response = await client.search({
  query: {
    span_term: {
      "user.id": {
        value: "kimchy",
        boost: 2,
      },
    },
  },
});
console.log(response);
GET /_search
{
  "query": {
    "span_term" : { "user.id" : { "value" : "kimchy", "boost" : 2.0 } }
  }
}

或者

resp = client.search(
    query={
        "span_term": {
            "user.id": {
                "term": "kimchy",
                "boost": 2
            }
        }
    },
)
print(resp)
response = client.search(
  body: {
    query: {
      span_term: {
        'user.id' => {
          term: 'kimchy',
          boost: 2
        }
      }
    }
  }
)
puts response
const response = await client.search({
  query: {
    span_term: {
      "user.id": {
        term: "kimchy",
        boost: 2,
      },
    },
  },
});
console.log(response);
GET /_search
{
  "query": {
    "span_term" : { "user.id" : { "term" : "kimchy", "boost" : 2.0 } }
  }
}