cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

LikeFilter syntax for multiple patterns?

SOLVED
Highlighted
Level 1

LikeFilter syntax for multiple patterns?

Hi all,

I'm trying to use the LikeFilter infotable function to filter some results in an infotable. I'm using the basic syntax like below:

var paramsForFilteredResult = {

    inclusive: true,

    fieldName: "ResultID",

    t:MyInfotableResult,

    pattern: "Result1"

};

var FilteredByResult = Resources["InfoTableFunctions"].LikeFilter(paramsForFilteredResult);

But I am wondering, is it possible using this function to search for multiple patterns? For example, what if I want to show Result1 and Result2, not just Result1? I have tried incorporating forloops and a number of different syntax approaches, but I don't seem to be having luck.

Any help is greatly appreciated!

- Jon

1 ACCEPTED SOLUTION

Accepted Solutions

Re: LikeFilter syntax for multiple patterns?

Hi Jon,

I did exactly a few hours ago a query to an Infotable, that's the exact code ( like it's the query string text ):

if (like) {

    result = Resources["InfoTableFunctions"].Query({

        t: result,

        query:  {

            "filters": {

                "fieldName": "name",

                "type": "LIKE",

                "value": ("*"+like+"*")

            }

        }

    });

}

12 REPLIES 12

Re: LikeFilter syntax for multiple patterns?

Usually for more complex filters I use Query

and this reference in the javadoc

Query Parameter for Query Services

Re: LikeFilter syntax for multiple patterns?

Thanks, Pai. I'll check it out.

Re: LikeFilter syntax for multiple patterns?

This was a big help! Thank you, Pai.

One question: I'm trying to use LIKE with a wildcard, but I'm not having luck. Here's what I'm trying:

"fieldName": "SystemStatus",

              "type": "LIKE",

               "value": "%Reason1%"

Is it as simple as this to return values? It isn't working for me. I also tried '*' + "Reason1" + '*' and a few other variations.

thanks,

Jon

Re: LikeFilter syntax for multiple patterns?

Hi Jon,

I use LIKE that way and it works:

{ "fieldName": "queryFieldName", "type": "LIKE", "value": ("*"+likeText+"*") }

Re: LikeFilter syntax for multiple patterns?

Hi Jon, did you try something like this "value": "*%Reason1%*"

Re: LikeFilter syntax for multiple patterns?

I have tried that, but it doesn't seem to be working.

Re: LikeFilter syntax for multiple patterns?

Jon,

Did you tried how I did sent to you? if it doesn't works, the problem should be another. You are querying directly a DataTable, Stream, ValueStream or a in-memory Infotable?

Best Regards,

Carles.

Re: LikeFilter syntax for multiple patterns?

Hi  Jon, You can use most of the regular expression that a java script supports, like Carles mentioned you can use '*' to filter data. Also day if you want to filter data while has 'Result' as prefix followed by a number then you can use "Result\\d", in this case you will get Result1, Resut2 but not Results ot Results1.

Another exaple is, if you want to filter all records with values a or b or c then you can use "[abc]"

Hope this helps,

Regards,

Siva

Re: LikeFilter syntax for multiple patterns?

Thanks for the followup, everyone.

I am working to implement what Charles mentioned, but am having some server issues at the moment. Will get it up and tested as soon as I can. Charles, I am trying to query an infotable.