cube-js / cube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics
https://cube.dev
Other
17.97k stars 1.78k forks source link

Cube schema for Nested Field in Elastic index #1070

Closed Vigneshg98 closed 4 years ago

Vigneshg98 commented 4 years ago

Consider I have the following data in my Elastic index. "hits" : [ { "_index" : "cubepoc", "_type" : "_doc", "_id" : "i1", "_score" : 1.0, "_source" : { "pname" : "john doe", "pconcern" : "cough and fever", "product" : [ { "medicine1" : "medomol", "medicine2" : "aspirin" } ] } } ]

So in order to access the product, I would need to do a nested query in elastic. How could I achieve the same through Cube.js schema?

The following is my cubejs schema.

cube(`Cubepoc`, {
  sql: `SELECT * FROM cubepoc`,

  joins: {},

  measures: {},

  dimensions: {
    pname: {
      sql: `pname`,
      type: `string`,
      title: `Patient Name`
    },
    pconcern: {
      sql: `pconcern`,
      type: `string`,
      title: `Patient Concern`
    },
    product: {
      sql: `product`,
      type: `string`,
      title: `Patient Product`
    }
  }
});

Since the product is of type nested in Elastic, defining it as string doesn't help to access it. Help me to generate the correct schema.

Thanks & Regards

RusovDmitriy commented 4 years ago

Hi Vignesh! So far ElasticSearch has limitations for SQL Access:

The cubejs-elasticsearch-driver uses built-in SQL support, which imposes restrictions on the use of nested data type