Skip to content

Commit

Permalink
Add regex tag filter for ES backend
Browse files Browse the repository at this point in the history
Signed-off-by: Annanay <annanayagarwal@gmail.com>
  • Loading branch information
annanay25 committed Jan 29, 2020
1 parent 0e974ce commit ca65f26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions plugin/storage/es/spanstore/fixtures/query_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{
"bool":{
"must":{
"match":{
"regexp":{
"tag.bat@foo":{
"query":"spook"
"value":"spook"
}
}
}
Expand All @@ -15,9 +15,9 @@
{
"bool":{
"must":{
"match":{
"regexp":{
"process.tag.bat@foo":{
"query":"spook"
"value":"spook"
}
}
}
Expand All @@ -37,9 +37,9 @@
}
},
{
"match":{
"regexp":{
"tags.value":{
"query":"spook"
"value":"spook"
}
}
}
Expand All @@ -62,9 +62,9 @@
}
},
{
"match":{
"regexp":{
"process.tags.value":{
"query":"spook"
"value":"spook"
}
}
}
Expand All @@ -87,9 +87,9 @@
}
},
{
"match":{
"regexp":{
"logs.fields.value":{
"query":"spook"
"value":"spook"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,14 @@ func (s *SpanReader) buildNestedQuery(field string, k string, v string) elastic.
keyField := fmt.Sprintf("%s.%s", field, tagKeyField)
valueField := fmt.Sprintf("%s.%s", field, tagValueField)
keyQuery := elastic.NewMatchQuery(keyField, k)
valueQuery := elastic.NewMatchQuery(valueField, v)
valueQuery := elastic.NewRegexpQuery(valueField, v)
tagBoolQuery := elastic.NewBoolQuery().Must(keyQuery, valueQuery)
return elastic.NewNestedQuery(field, tagBoolQuery)
}

func (s *SpanReader) buildObjectQuery(field string, k string, v string) elastic.Query {
keyField := fmt.Sprintf("%s.%s", field, k)
keyQuery := elastic.NewMatchQuery(keyField, v)
keyQuery := elastic.NewRegexpQuery(keyField, v)
return elastic.NewBoolQuery().Must(keyQuery)
}

Expand Down

0 comments on commit ca65f26

Please sign in to comment.