Elasticsearch 跨索引库搜索

本文介绍了Elasticsearch中如何进行跨索引库搜索,重点讨论了使用_mapping元数据字段和_index字段来实现精确查询。通过在bool的should查询中加入_index,可以避免因不同索引库相同字段导致的重复数据问题,从而优化搜索体验。
摘要由CSDN通过智能技术生成

跨索引库搜索

mapping元数据字段

Metadata fields are used to customize how a document’s associated metadata is treated.
元数据字段用于自定义处理文档相关元数据

Identity metadata fields 身份元数据

  • _index

The index to which the document belongs. 文档所在索引库

  • _type

The document’s mapping type.

  • _id

The document’s ID. 文档唯一标识

注意 _index _id 可用于 query 查询

_index 查询,包括跨索引库查询,_bulk 查询,_mget 查询,_search 查询,_msearch 查询

PUT index_1/_doc/1
{
  "text": "Document in index 1"
}

PUT index_2/_doc/2?refresh=true
{
  "text": "Document in index 2"
}

GET index_1,index_2/_search
{
  "query": {
    "terms": {
      "_index": ["index
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值