Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blendb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C3SL
blendb
Commits
0ce1a94d
Commit
0ce1a94d
authored
6 years ago
by
Felipe Wu
Browse files
Options
Downloads
Patches
Plain Diff
[006] sort, datatype finalizado
Signed-off-by:
Felipe Wu
<
felipeshiwu@gmail.com
>
parent
53427b55
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#20110
failed
6 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/adapter/elasticsearch.ts
+27
-15
27 additions, 15 deletions
src/adapter/elasticsearch.ts
with
27 additions
and
15 deletions
src/adapter/elasticsearch.ts
+
27
−
15
View file @
0ce1a94d
import
{
View
}
from
"
../core/view
"
;
import
{
View
}
from
"
../core/view
"
;
import
{
Source
}
from
"
../core/source
"
;
import
{
Source
}
from
"
../core/source
"
;
import
{
FilterOperator
}
from
"
../core/filter
"
;
import
{
FilterOperator
}
from
"
../core/filter
"
;
import
{
Metric
}
from
"
../core/metric
"
;
import
{
Adapter
}
from
"
../core/adapter
"
;
import
{
Adapter
}
from
"
../core/adapter
"
;
import
{
DataType
,
AggregationType
}
from
"
../common/types
"
;
import
{
DataType
,
AggregationType
}
from
"
../common/types
"
;
import
{
Client
,
ConfigOptions
}
from
"
elasticsearch
"
;
import
{
Client
,
ConfigOptions
}
from
"
elasticsearch
"
;
...
@@ -70,10 +71,10 @@ export class ElasticsearchAdapter extends Adapter {
...
@@ -70,10 +71,10 @@ export class ElasticsearchAdapter extends Adapter {
*/
*/
public
getDataFromView
(
view
:
View
,
cb
:
(
error
:
Error
,
result
?:
any
[])
=>
void
):
void
{
public
getDataFromView
(
view
:
View
,
cb
:
(
error
:
Error
,
result
?:
any
[])
=>
void
):
void
{
const
query
=
this
.
getQueryFromView
(
view
);
const
query
=
this
.
getQueryFromView
(
view
);
if
(
view
.
clauses
.
length
==
0
||
view
.
dimensions
.
length
>
1
)
{
if
(
view
.
clauses
.
length
>
0
||
view
.
dimensions
.
length
==
1
)
{
this
.
executeQuery
(
view
.
operation
.
values
[
0
].
name
,
query
,
cb
);
}
else
{
this
.
executeQuery
(
view
.
operation
.
values
[
0
].
operation
.
values
[
0
].
name
,
query
,
cb
);
this
.
executeQuery
(
view
.
operation
.
values
[
0
].
operation
.
values
[
0
].
name
,
query
,
cb
);
}
else
{
this
.
executeQuery
(
view
.
operation
.
values
[
0
].
name
,
query
,
cb
);
}
}
}
}
...
@@ -129,7 +130,7 @@ export class ElasticsearchAdapter extends Adapter {
...
@@ -129,7 +130,7 @@ export class ElasticsearchAdapter extends Adapter {
let
partialQuery
=
{};
let
partialQuery
=
{};
for
(
let
i
=
0
;
i
<
view
.
metrics
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
view
.
metrics
.
length
;
i
++
)
{
func
=
this
.
getAggregateFunction
(
view
.
metrics
[
i
].
aggregation
);
func
=
this
.
getAggregateFunction
(
view
.
metrics
[
i
].
aggregation
);
aggrName
=
func
+
"
_
"
+
view
.
metrics
[
i
].
name
.
toLowerCase
();
aggrName
=
view
.
metrics
[
i
].
name
.
toLowerCase
();
Object
.
assign
(
partialQuery
,
{
[
aggrName
]:
{[
func
]:
{
field
:
view
.
metrics
[
i
].
name
}}});
Object
.
assign
(
partialQuery
,
{
[
aggrName
]:
{[
func
]:
{
field
:
view
.
metrics
[
i
].
name
}}});
}
}
return
partialQuery
;
return
partialQuery
;
...
@@ -138,10 +139,16 @@ export class ElasticsearchAdapter extends Adapter {
...
@@ -138,10 +139,16 @@ export class ElasticsearchAdapter extends Adapter {
if
(
view
.
dimensions
.
length
>
0
)
{
if
(
view
.
dimensions
.
length
>
0
)
{
let
group_by
=
"
group_by_
"
+
view
.
dimensions
[
numDimensions
].
name
;
let
group_by
=
"
group_by_
"
+
view
.
dimensions
[
numDimensions
].
name
;
let
dim
=
view
.
dimensions
[
numDimensions
].
name
;
if
(
view
.
dimensions
[
numDimensions
].
dataType
<
3
)
{
dim
=
dim
;
}
else
{
dim
=
dim
+
"
.keyword
"
;
}
let
aggregation
=
{
let
aggregation
=
{
[
group_by
]:
{
[
group_by
]:
{
terms
:
{
terms
:
{
field
:
view
.
dimensions
[
numDimensions
].
name
+
"
.keyword
"
,
field
:
dim
,
size
:
100000
size
:
100000
},
},
aggs
:
{}
aggs
:
{}
...
@@ -150,6 +157,11 @@ export class ElasticsearchAdapter extends Adapter {
...
@@ -150,6 +157,11 @@ export class ElasticsearchAdapter extends Adapter {
Object
.
assign
(
aggregation
[
group_by
],
{
aggs
:
returnedQuery
});
Object
.
assign
(
aggregation
[
group_by
],
{
aggs
:
returnedQuery
});
if
(
numDimensions
==
view
.
dimensions
.
length
-
1
&&
view
.
sort
.
length
>
0
)
{
let
aggrName
=
view
.
sort
[
0
].
name
.
toLowerCase
();
Object
.
assign
(
aggregation
[
group_by
].
terms
,
{
order
:
{[
aggrName
]
:
"
asc
"
}});
}
return
aggregation
;
return
aggregation
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment