Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4e387ed4
Commit
4e387ed4
authored
Sep 05, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Elasticsearch and adhoc filters fix, fixes #9165
parent
52676161
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
public/app/plugins/datasource/elasticsearch/query_builder.js
+5
-2
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+5
-4
No files found.
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
4e387ed4
...
...
@@ -135,6 +135,7 @@ function (queryDef, _) {
}
var
i
,
filter
,
condition
,
queryCondition
;
for
(
i
=
0
;
i
<
adhocFilters
.
length
;
i
++
)
{
filter
=
adhocFilters
[
i
];
condition
=
{};
...
...
@@ -144,10 +145,12 @@ function (queryDef, _) {
switch
(
filter
.
operator
){
case
"="
:
_
.
set
(
query
,
"query.bool.must.match_phrase"
,
queryCondition
);
if
(
!
query
.
query
.
bool
.
must
)
{
query
.
query
.
bool
.
must
=
[];
}
query
.
query
.
bool
.
must
.
push
({
match_phrase
:
queryCondition
});
break
;
case
"!="
:
_
.
set
(
query
,
"query.bool.must_not.match_phrase"
,
queryCondition
);
if
(
!
query
.
query
.
bool
.
must_not
)
{
query
.
query
.
bool
.
must_not
=
[];
}
query
.
query
.
bool
.
must_not
.
push
({
match_phrase
:
queryCondition
});
break
;
case
"<"
:
condition
[
filter
.
key
]
=
{
"lt"
:
filter
.
value
};
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
4e387ed4
...
...
@@ -40,8 +40,7 @@ describe('ElasticQueryBuilder', function() {
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'count'
,
id
:
'1'
}],
timeField
:
'@timestamp'
,
bucketAggs
:
[
{
type
:
'terms'
,
field
:
'@host'
,
id
:
'2'
},
bucketAggs
:
[
{
type
:
'terms'
,
field
:
'@host'
,
id
:
'2'
},
{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'3'
}
],
});
...
...
@@ -282,6 +281,7 @@ describe('ElasticQueryBuilder', function() {
bucketAggs
:
[{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'3'
}],
},
[
{
key
:
'key1'
,
operator
:
'='
,
value
:
'value1'
},
{
key
:
'key2'
,
operator
:
'='
,
value
:
'value2'
},
{
key
:
'key2'
,
operator
:
'!='
,
value
:
'value2'
},
{
key
:
'key3'
,
operator
:
'<'
,
value
:
'value3'
},
{
key
:
'key4'
,
operator
:
'>'
,
value
:
'value4'
},
...
...
@@ -289,8 +289,9 @@ describe('ElasticQueryBuilder', function() {
{
key
:
'key6'
,
operator
:
'!~'
,
value
:
'value6'
},
]);
expect
(
query
.
query
.
bool
.
must
.
match_phrase
[
"key1"
].
query
).
to
.
be
(
"value1"
);
expect
(
query
.
query
.
bool
.
must_not
.
match_phrase
[
"key2"
].
query
).
to
.
be
(
"value2"
);
expect
(
query
.
query
.
bool
.
must
[
0
].
match_phrase
[
"key1"
].
query
).
to
.
be
(
"value1"
);
expect
(
query
.
query
.
bool
.
must
[
1
].
match_phrase
[
"key2"
].
query
).
to
.
be
(
"value2"
);
expect
(
query
.
query
.
bool
.
must_not
[
0
].
match_phrase
[
"key2"
].
query
).
to
.
be
(
"value2"
);
expect
(
query
.
query
.
bool
.
filter
[
2
].
range
[
"key3"
].
lt
).
to
.
be
(
"value3"
);
expect
(
query
.
query
.
bool
.
filter
[
3
].
range
[
"key4"
].
gt
).
to
.
be
(
"value4"
);
expect
(
query
.
query
.
bool
.
filter
[
4
].
regexp
[
"key5"
]).
to
.
be
(
"value5"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment