Skip to content

Conversation

@wuyunfeng
Copy link
Member

@wuyunfeng wuyunfeng commented Jun 29, 2020

#3967

Create multiple index with same mapping in ES:

PUT wildcard_1
{
   "settings": {
      "number_of_replicas": 0,
      "number_of_shards": 1
   },
   "mappings": {
      "doc": {
         "properties": {
            "k1": {
               "type": "integer"
            },
            "k2": {
               "type": "keyword"
            }
         }
      }
   }
}

PUT wildcard_2
{
   "settings": {
      "number_of_replicas": 0,
      "number_of_shards": 1
   },
   "mappings": {
      "doc": {
         "properties": {
            "k1": {
               "type": "integer"
            },
            "index": {
               "type": "keyword"
            }
         }
      }
   }
}

PUT wildcard_3
{
   "settings": {
      "number_of_replicas": 0,
      "number_of_shards": 1
   },
   "mappings": {
      "doc": {
         "properties": {
            "k1": {
               "type": "integer"
            },
            "index": {
               "type": "keyword"
            }
         }
      }
   }
}

k2 used for indicating the data from which index

Create wildcard_alias aliases contains those above three index:

POST /_aliases
{
   "actions": [
      {
         "add": {
            "indices": [
               "wildcard_3",
               "wildcard_2",
               "wildcard_1"
            ],
            "alias": "wildcard_alias"
         }
      }
   ]
}

Create ES external table within Doris:

  • Support aliase matched index:
CREATE EXTERNAL TABLE `wildcard_alias` (
  `k1` int COMMENT "",
   `k2`  varchar COMMENT ""
) ENGINE=ELASTICSEARCH
PROPERTIES (
"hosts" = "http://127.0.0.1:8200",
"user" = "root",
"password" = "root",
"index" = "wildcard_alias",
"type" = "doc",
"version" = "6.5.3",
"enable_docvalue_scan" = "true"
);
  • Support wildcard matched index (pattern: wildcard_*):
CREATE EXTERNAL TABLE `wildcard_alias` (
  `k1` int COMMENT "",
   `k2`  varchar COMMENT ""
) ENGINE=ELASTICSEARCH
PROPERTIES (
"hosts" = "http://10.74.167.16:8200",
"user" = "root",
"password" = "root",
"index" = "wildcard_*",
"type" = "doc",
"version" = "6.5.3",
"enable_docvalue_scan" = "true"
);

And execute SQL on Doris:

 select * from wildcard_alias;
  or
 select * from wildcard;

Finally we get all document within those three index:

+------+-------------+
| k1   | k2          |
+------+-------------+
|  111 | wiladcard_1 |
| 1111 | wiladcard_1 |
| 1112 | wiladcard_1 |
|  110 | wiladcard_1 |
|  222 | wiladcard_2 |
|  223 | wiladcard_2 |
|  223 | wiladcard_2 |
|   33 | wiladcard_3 |
|   33 | wiladcard_3 |
|   33 | wiladcard_3 |
|   33 | wiladcard_3 |
|   33 | wiladcard_3 |
+------+-------------+

BTW: predicates which can push down would push down to all related indices

@BabySid
Copy link
Contributor

BabySid commented Jun 29, 2020

looks good.
but i have a question: sql like 'select k1 from wildcard_alias where k1 > '2020-05-20'', DSL will run on all related indices? or just on wildcard_alias_2020_05_21, wildcard_alias_2020_05_22...

@wuyunfeng
Copy link
Member Author

wuyunfeng commented Jun 29, 2020

@blackfox1983 yes, run on all related indices. process predicate is independent with processing resolved indidces

@wuyunfeng wuyunfeng force-pushed the support-multiindex branch from 96b76c8 to e2e945c Compare June 29, 2020 06:22
@wuyunfeng wuyunfeng changed the title [Doris On ES] Support create table with wildcard or aliase index [Doris On ES][Feature] Support create table with wildcard or aliase index Jun 29, 2020
@wuyunfeng wuyunfeng force-pushed the support-multiindex branch from e2e945c to f4214c8 Compare June 30, 2020 01:42
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morningman morningman added approved Indicates a PR has been approved by one committer. area/doris-on-es Issues or PRs related to Doris on ElasticSearch labels Jun 30, 2020
@morningman morningman merged commit 2362500 into apache:master Jul 1, 2020
@wuyunfeng wuyunfeng deleted the support-multiindex branch July 1, 2020 14:39
morningman pushed a commit to morningman/doris that referenced this pull request Jul 6, 2020
@EmmyMiao87 EmmyMiao87 mentioned this pull request Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/doris-on-es Issues or PRs related to Doris on ElasticSearch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants