regex in query

334 views
Skip to first unread message

awang

unread,
Jul 17, 2012, 8:15:46 PM7/17/12
to druid-de...@googlegroups.com
Hi Duid Developers,

I am wondering if Druid support regex as a filter type for queries. For example, can I build the following type of queries with regex:

* search in a dimension for values that match the regex and display matching rows 
* Aggregate in a dimension while filtering rows with regex in the same or a different dimension.

Some examples will be great.

Thanks,
Allen

Eric Tschetter

unread,
Jul 27, 2012, 3:42:55 PM7/27/12
to druid-de...@googlegroups.com
Hi Allen,

Sorry it took a while to respond. This message got caught up in some
filters and skipped. I've added a prefix to the subject lines for
messages to this group so that hopefully that doesn't happen again.


> I am wondering if Druid support regex as a filter type for queries. For
> example, can I build the following type of queries with regex:
>
> * search in a dimension for values that match the regex and display matching
> rows
> * Aggregate in a dimension while filtering rows with regex in the same or a
> different dimension.

You are supposed to be able to use a regex in a filter, but Druid (at
least the current code) is built around the idea of creating
aggregations of rows that match a filter, not necessarily showing the
individual rows that match the filter. Returning individual rows can
be done, but the code to do it is not presently available. Looking
over the code for it, though, I don't think it's working. We actually
only use it in a special case scenario and that's all that's currently
working for us. I'll add this to the code and let you know. When I'm
done, the syntax will look like

{
"type": "regex",
"dimension": some_dimension,
"expr": expression
}

> Some examples will be great.

I'll try to write up some example query objects.

--Eric


>
> Thanks,
> Allen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Druid Development" group.
> To post to this group, send email to druid-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> druid-developm...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/druid-development/-/7ZU4mEDvHkgJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Eric Tschetter

unread,
Jul 31, 2012, 2:45:39 AM7/31/12
to druid-de...@googlegroups.com
Allen,

I just pushed the changes that will add the regex filter. It's
slightly different syntax from what I previously said:

{
"type": "regex",
"dimension": some_dimension,
"pattern": expression
}

If you pull, you should get it. I'll try to write up some more docs
with query examples sometime this week.

--Eric
Reply all
Reply to author
Forward
0 new messages