Searching data from REST API for input variable

So i have this data collection from REST API:

SELECT(data[“ID1-Collection”], item.group_name==“My Media”)

Which returns a dataset which is categorized under the name My Media.

it has “name” item (among other things) which holds the name of a file.

I then create a search box which input field is bound to an app var named “searchvar” (without the quotes ofcourse).

For now i have a component tap on the search bar:

which opens the page Search Results.

On that page i have a container which repeats data from the collection.

What i want is to use the (app.)searchvar variable to select items from the collection which holds or partially holds the value that searchvar holds.

For example: if i search for “new”, i want the results to look like this:

This is a new movie.mp4
New.mp4
Old and new.jpg

Like in PHP where you have the ‘Like’ operator.

Does anyone know how to do this?

Thanks!

Rienk

Anyone?

Would be of great help!

Thanks!

Rienk

Hey @Rienk_Boorsma, sorry for taking long to reply. Check out the CONTAINS formula function (docs) :slight_smile: This power-up could also be interesting for you!

Hi Mari,

Thanks for reply!

I had a look at the power-up and formulas but still can’t figure it out.

I have a REST API resource, which is set to a data variable called ‘databasrecords_IDL’ using Get Collection.

I have a page with an appVar named ‘searchvar’ which is set as a list-type.

I bind that to an input field/search box and take it to the next page where the search results are supposed to show.

I try to get the data using SELECT:

SELECT(data.databaserecords_IDL[0].file_name, appVars.searchvar)

So that file_name is searched for appVars.searchvar.

What i get is ‘Text type is not assignable to list type’

Does it mean i can’t search the datavar using an appvar? Or is my function syntax wrong…

Thanks!
Rienk

Hi Rienk, one thing that comes to mind is that why is searchvar a list? Shouldn’t it be a text if it’s the word that you’re searching for?

Hi Mari,

It was text before i changed it to list and that did not work either. I am trying different things to get it to work.

Was there anything wrong with the syntax?

Hi, by choosing data.databaserecords_IDL[0] you are restricting the search to only the first item in the list.

Try SELECT(data.databaserecords_IDL, CONTAINS(item.file_name, appVars.searchvar)). That chooses all the items in the list, for which the CONTAINS formula evaluates to true.

Thanks Mari, gonna try it!

Hi Mari,

That worked, thanks!

Btw if i enter something in the input-field and press enter, nothing happens. When i press the magnifying glass icon several times, i get the new page with the right results.
Do you know how ENTER will go to the new page i am calling?

Thanks,
Rienk