Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
destruk
Streaming Star

Re: Roku Search Bar

I did a bit more digging and this is 30% faster for a local search, so thanks, I learned something.
'Create Searchresults Array
searchresults=[]

'create associative array for faster searchingg
clist={}

'Loop through content list categories
For x=0 To m.masterlist.count()-1
   'Loop through items in each category
   For y=0 To m.masterlist[x].count()-1
      'If search term is 1 character long, then check for matches based on title only
      If Len(FinalSearchTerm)=1
         'search titles that begin with that character and skip other fields
         If LCASE(m.masterlist[x][y].Title.Left(1))=LCASE(FinalSearchTerm)
    If clist.doesexist(m.masterlist[x][y].contentID)=FALSE
searchresults.push(m.masterlist[x][y])
clist.AddReplace(m.masterlist[x][y].contentID,0)
    End If
         End If
      Else
         If(Instr(1,LCASE(m.masterlist[x][y].Title),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Director),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[0]),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[1]),LCASE(FinalSearchTerm))>0) or (Instr(1,LCASE(m.masterlist[x][y].Actors[2]),LCASE(FinalSearchTerm))>0)  or (Instr(1,LCASE(m.masterlist[x][y].Description),LCASE(FinalSearchTerm))>0) or (Instr(1,m.masterlist[x][y].ReleaseDate,FinalSearchTerm)>0)
    If clist.doesexist(m.masterlist[x][y].contentID)=FALSE
searchresults.push(m.masterlist[x][y])
clist.AddReplace(m.masterlist[x][y].contentID,0)
    End If
         End If
      End If
   Next
Next
0 Kudos
norcaljohnny
Roku Guru

Re: Roku Search Bar

"destruk" wrote:
"norcaljohnny" wrote:
With all due respect 3-4 seconds is extremely slow. With 19,000 items my results return in .2 seconds via server side and php.

And with all due respect it could take 3-4 seconds to download the data from your server to the client app.  So... you know, we can argue about which is better for months if you prefer, but really it's up to the individual channel developer to decide what they want to use. While results might return from your server it still takes the roku devices (low end and roku 4) 5 seconds to parse the results for 19,000 items, so that is still slow.  But since3 you can't make that part faster, well.... Maybe chill out, we're not fighting here, we are discussing different techniques to accomplish a goal dude.

Please know I am not trying to argue anything out with you. I know you are extremely helpful in the forums and have learned from your past posts a dozen times at least.
So please believe me when I say with all due respect, as its from the heart. I just wanted to present something different. 
As far as the downloading the master list to the client, it never does. It only returns the results based on the user input. So even if the master list may be 7 megs it never poses a problem because the search happens server side and the returned results are about 10k if that. And that is what makes it so fast. 
Again Im just bouncing things around to see if there are methods outside the roku sdk that we can benefit from. Cheers
0 Kudos
destruk
Streaming Star

Re: Roku Search Bar

Both methods can be even quicker if you limit the results with paging - only sending 20-50 items from the server or doing the search in 50 item chunks and adding a "select for more" to grab the next page of results.  In my own experience, the master full content list could be transferred one time when the app loads after the user logs in.  We were doing that for smaller channels with fewer than 500 items and that allowed us to use low-power servers to handle hundreds of users per hour and was sufficient.  I realize your user base is most likely higher, and you have a lot more content than we have dealt with here, and I do agree if money was available for more powerful servers and connectivity, us handing off the harder tasks to the server would be a better idea for scalability.
0 Kudos
lylyahiko
Visitor

Re: Roku Search Bar

For the actual search bar itself. When I select the button to search a Poster Node needs to be created with a minikeyboard attached to it. How would I go about doing that?
0 Kudos
destruk
Streaming Star

Re: Roku Search Bar

I would create a group, add a rectangle, and within that add the minikeyboard, set the group to visible and set focus to the minikeyboard.  https://sdkdocs.roku.com/display/sdkdoc/MiniKeyboard
0 Kudos
destruk
Streaming Star

Re: Roku Search Bar

You'll also need a button involved to accept the input and hide/get rid of the search box.
0 Kudos
norcaljohnny
Roku Guru

Re: Roku Search Bar

"lylyahiko" wrote:
For the actual search bar itself. When I select the button to search a Poster Node needs to be created with a minikeyboard attached to it. How would I go about doing that?

The search bar/screen I use resembles apple tv 4 search screen. I can share the complete code with you or if you wish I can write a code using the minikeyboard to it...
0 Kudos
MarlonC
Visitor

Re: Roku Search Bar

"norcaljohnny" wrote:
Here is a sample of how i do it

1st I have a master file in xml format, no database needed.
I named it "all.xml" and place it in the root folder of my server.

Sample:

<?xml version = "1.0" encoding = "utf-8" standalone = "yes" ?>
  <Content>
    <item url="a_bit_of_fry_and_laurie" title="A Bit of Fry and Laurie" year="1987" hdposterurl="yourPosterUrl"/>
  </Content>



2nd i create a search script that will return the results.
I name it "livesearch.php" and place it in the root folder of my server.
"\n" =  end of line and "i" =  not case sensitive
I then append the url to a base url that handles the actual video file on click of the results.

Sample:

<?php header("Content-type: text/xml")?>
<?php echo "<?xml version = \"1.0\" encoding = \"utf-8\" standalone = \"yes\" ?>\n" ?>
  <?php echo "<Content>\r\n" ?>
    <?php
      $q=$_GET["q"];
      $xml=file_get_contents("all.xml");
      preg_match_all("/.*title=\".*$q.*\"*\n/i", $xml, $output,PREG_SET_ORDER);
      foreach($output as $file){
      $file= $file[0];
      echo "$file";
      } 
<?php echo "</Content>" ?>

 
So now if I go to "https://myWebAddress.com/livesearch.php?q=searchTextInput" it gets returned with all results parsed in a Roku xml format. 
I also use a function so the results are returned as they type and not by a search button being pressed.

This method also allows all results returned regardless of where the word falls in the search and you dont have to worry about exact matches.

IE ... "https://myWebAddress.com/livesearch.php?q=brady" will return "the brady bunch" assuming that is a file.

Interesting.  I didn't know it was possible to use php.  I am versed in PHP.  However, ban new to scenegraph/brightscript.  I see clearly how to get this to show on a PHP web page.  But how would I integrate this with Scenegraph/brightscript?  
Thanks
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.