Sign In Register

How can we help you today?

Start a new topic

gs-query-field with regex


I am trying to build an admin screen for viewing RT logs. (copying the script log screen - Sean already wrote me a base)

is there a way to put a regex field in gs-query-field? specifically for parsing the log messages

or should I put a message filter outside gs-query and edit the code ad-hoc?

Hi Mauro,

The data that's passed into the query is then passed into another snippet processor, where the query json can be grabbed and used for querying any of the collections you may want information out of. It largely depends on whether or not the query going in will be valid. You could also use the query builder for creating a partial query, and then transforming it before the actual query gets carried out. 

Let me know if that answers your question or if you have any additional questions.


ok. so I could i.e. add a "regex" operator and put {<field>: {$regex: <value>}} in the relevant place? can I intercept gs-query fields being built?

or it's easier to insert a separate "message regex" data in the form outside gs-query and manage it separately?

regex isn't an operator allowed in the query-builder rules but yes you could do something allong the lines of:

<field> equals ["$regex <value>"] and intercept the query in the JavaScript of the Manage screen to then fix your query in whatever way you'd like. 

It's difficult to say what is the better workflow, The query builder isn't strictly made for regex queries so you might be better off just making your own system that just accepts inputs and infers that some regular expression is about to be passed in.


yes for now I have a separate "message regex" input and if it's not empty I directly do


if (data.message)
    query.message = {$regex:data.message};

 in the processor.

downside is (1) it's fixed on the "message" field (but this is all what I need for now) and (2) it's always a top-level $and and I cannot put this into the built query tree

an alternative would be to recursively parse all the query field with a regex that matches my regex enabler (something like this? "^\$regex\ (.*)$") and replace it with {$regex: \1} (insert "yo dawg, i heard you like regex" meme here)

Login to post a comment