Search engine creation


(Simon) #1

Hello, I’d like to add a search function within a basic app that then returns results with a clickable link.

How is this possible??

Simon


Info su modulo ricerca
#2

All due respect Simon. You have to at least come up with something and then ask for help. I mean, we are very, very helpful here but I’m sure I speak for most here when I say we don’t necessarily have the time to create something for you.

A few questions,

Is the search for information within the app itself?
Have you made the app yet?
Can you share anything you’ve tried?
Why do you need a search function?
How is the information stored in your “app”?


(Simon) #3

Hi D,

Fair enough… Bit vague! I was on the bus home and ideas kept jumping into my head…

Ok, basic setup is a small iPhone app, created in Hype.

At work we have around 60 meeting rooms, all sizes scattered over 6 floors.

I’m looking to create a basic app that has the details of each room… I.e. Name, Location, Size and an image…

I’ve made the graphics and I’m just thinking about how to make it in hype. Should be straight forward. Although the one area I’m unsure off is adding a search function. A button at the bottom, tap, search for a room and then choose from a list… Click the name and it launches a ‘page’ for that room…

All info will be created as text in hype.

Can I add this search function? Or will I have to look at doing it in Xcode?

Thanks for any help!

Simon


#4

ok. maybe you could create something that when the user inputs a search term you can match that to the information and only show the rooms based on that information.

Here is a link to something made before that might help

Instead of having a clickable list of items you could adapt it to use a user input instead.


(Simon) #5

This is a tidy effect… But it’s not a search. it would filter like minded rooms… But not find a room called ‘New York’ or ‘Washington’

I would like to be able to type ‘Wa’ and The Washington link/card/screen appear… Maybe a table view…

I imagine this can’t be done in Hype??. And need to look at combining hype html with Xcode…

You experts agree??!


#6

Did you notice when I said “adapt” i.e you could have the same functionality but match the input given to the name field of the rooms. So, when the user started to type you could match that to the name and display the chosen one.

May I suggest getting something up and running and then coming back for any additional help.

Another way would be to hold the list of rooms as an array item and then match the user input to that list.

to be honest there are probably many ways to do what you are wanting to do but I certainly don’t have time to hand hold you through the process. It can be done! I have suggested a possible way but I’ll leave it for others to chime in if they so wish.


(Simon) #8

Thanks D… I’ll try and build what I can and then come back.

I’m fine with drag and drop type software and things like after effects… But code, is a black hole!

Thanks for your help! This forum is brilliant and your one of the top guys…!

Simon


#9

For a search engine to look through regular HTML, check out http://lunrjs.com, though this would require some setup & code.

I use it in the documentation, and you can see it in action in the search box in the upper left hand corner. It makes an index of all H1s and H2s and adds their text content to the search index and makes a little ‘search results’ box below when typing in the input field.


Search engine within Hype document
(Mark Hunte) #10

Don’t forget that if you are using a WKWebView you can interact in both directions from your Cocoa (Swift/Objective - c) code and the javascript of the html.

So in theory you could use an Xcode Search Field (NSSearchField) for user input and a list done in the Xcode app itself that will return the correct rooms by controlling the Scenes.

I wrote an example thread here that shows some interaction. the App controlling scenes and the HTML/js controlling the App.

Some of it maybe out of date now but you should be able to work out whats what. And Xcode will update the project as normal.


(Casey) #11

Would this be a similar approach if I wanted to integrate a search system into a 30+ scene project? Or, is there an approach/process that would be best to use? I’m thinking of creating an interactive guide in Hype (lots of dense text and most likely 30+ scenes) but need to have a decent search system integrated in it.


#12

That search engine works well when all the H1, H2, or other HTML elements you want to index are all on the same page. Out of the box it wouldn’t be able to handle elements or text across multiple scenes since the default behavior jumps to the ‘found’ element by scrolling.

The approach for what you’re talking about would require:

  • Structuring a scene so that some sort of predefined element (it could be H2s, or even elements with a certain classname) are added to a search index
  • The index contains: that keyword’s scene name and the position (The Hype api would make this easier)
  • When searching for a keyword, clicking on that result would first jump you to that scene, then scroll you to the keyword’s position.

With all this said, Lunr might be adaptable to your needs if you are interested in digging into its inner workings.