简体   繁体   English

elasticsearch通配符索引类型

[英]elasticsearch wildcard index type

In elasticsearch, is it possible to define wildcard types (index)? 在Elasticsearch中,是否可以定义通配符类型(索引)?

For example: I have an index named miner and have types P1, P2, N1, N2. 例如:我有一个名为miner的索引,类型为P1,P2,N1,N2。

I want to search index: miner with all types starting with 'P'. 我想搜索索引:以'P'开头的所有类型的矿工。 I tried 'P*' and does not work. 我尝试了“ P *”,但不起作用。 Is it possible? 可能吗?

client.search({
  index: 'miner',
  type: 'P*',

Thank you 谢谢

You need a prefix query for field _type . 您需要对字段_type进行前缀查询。 My example below demonstrates the prefix query together with whatever else you would like to search your index: 下面的示例演示了prefix查询以及您要搜索索引的其他内容:

GET /miner/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "prefix": {
            "_type": {
              "value": "test"
            }
          }
        },
        {
          "match": {
            "name": "bob"
          }
        }
      ]
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM