Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 13    Views: 87

Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
05/24/13 02:50 AM (12 years ago)

Search plugin mod for keyword searching

I'm trying to customize the search plugin to enable searching of more than just the screen titles... I approached this by modifying the PHP to add a JSON value of "keywordSearch" with the goal being to have these keywords hidden from the user, while still filtering to the respective screen in the search screen. eg, "navBarTitleText":"Cars", "keywordSearch":"BMW Ford" If the user enters BMW, Ford, or Cars into the search bar, it should filter to the Cars screen. I'm stuck on how to modify the code to add this keywordSearch value to the data used for filtering. I'm not a programmer by any means, but this is the close I can figure as to where the dictionary values are determined? (which doesn't work) NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: [thisScreen itemId], @"loadScreenWithItemId", menuTitle, @"titleText", @"", @"keywordSearch", @"", @"descriptionText", nil]; [thisMenuItemData setJsonVars:dict]; [self.menuItems addObject:thisMenuItemData]; Does my new keywordSearch value need to be declared elsewhere? How can I get the search to use these keywords for filtering? Appreciate any help from this great community!
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
05/24/13 04:02 AM (12 years ago)
I tried doing the same exact thing awhile ago! I think I got to the point I could search for keywords but only keywords, no navtitle. WHich I was willing to work with. But I could only get the results dispayed as the keywords and not the screen title which just wasn't going to work. I gave up and haven't gone back to it since.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/24/13 04:15 AM (12 years ago)
I don't have the code in front of me to look at, but there must be something else you're not showing. All this does is create an array of dictionaries. There has to be some code that looks at the array to do the search.
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
05/24/13 04:54 AM (12 years ago)
Keywords are a great start, but I wish someone could make a search plugin that searched EVERYTHING including the entire html files. I've seen apps do this but no clue how to do it myself. Any takers?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/24/13 05:03 AM (12 years ago)
Could probably develop something like this for you if you can wait a bit. I have several pending requests, though most aren't confirmed yet.
 
Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
like
05/24/13 05:05 AM (12 years ago)
@mutzy - Ha! Having the exact same problem. Seems to be more complex than I anticipated! @chris1 - I believe this is where it does the filtering based on "titleText". I'm pretty much stuck though on how to get my JSON keyword list included in the filtering while keeping the menu titles and not displaying the keywords. Any chance on being able to implement a full html search as a plugin? You'd have at least 2 customers! //text field changed -(void)textFieldDidChange:(id)sender{ //NSLog(@"textFieldDidChange"); //remove filtered items [filteredMenuItems removeAllObjects]; //remember the searched value for next time (in case we leave the screen and come back) [BT_strings setPrefString:@"currentSearchValue":[searchBox text]]; //search on every character... if([searchBox.text length] > 0){ //loop through items in menu data... for(int i = 0; i < [self.menuItems count]; i++){ BT_item *thisItem = [self.menuItems objectAtIndex:i]; NSRange r = [[thisItem.jsonVars objectForKey:@"titleText"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; if(r.location != NSNotFound){ //if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; //} } } }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/24/13 05:31 AM (12 years ago)
An easy way is to copy and paste that loop just below the loop and change titleText to your new JSON value. As for the HTML search, the two of you could split the cost for me to do it. Lets try to do a Google Hangout next week to talk about it?
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
05/24/13 06:01 AM (12 years ago)
Heh, I'm actually looking into expanding my search plugin the same way. But it will probably be better for @chris to do it as he's a plugin genius that will find all kinds of better ways to do it then me - and without bugs. I would highly recommend hiring him for this, as there is no way I will be getting something like this done for at least 3-5 months. Cheers, David
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
05/24/13 08:10 AM (12 years ago)
Hi all, See the problem here and I also can develop a solution for this. For the html search, that's a different story. This is because the search plugin searches all the json items and an html page is only referenced with a url (so the actual data from the html is not included and therefor not searchable). If anyone is interested send me a pm with detailed information regarding the customization. Best regards Danny
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/24/13 08:19 AM (12 years ago)
No worries - I can develop the HTML search easy enough.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
05/24/13 08:25 AM (12 years ago)
Ok than you're the man they should be talking to. Best Regards, Danny
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
05/24/13 08:59 AM (12 years ago)
I will definitely pay for this, esp if you can do it for Android as well!
 
Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
like
05/24/13 10:05 PM (12 years ago)
I'm in for the HTML search too. I tried doing what @chris1 suggested to get the keyword search going by duplicating the loop, but it still doesn't use the keywords for filtering. The menu title search still works, but it then brings the search term to the top of the list, while still displaying (or duplicating) the unfiltered list below the found term. //search on every character... if([searchBox.text length] > 0){ //loop through items in menu data... for(int i = 0; i < [self.menuItems count]; i++){ BT_item *thisItem = [self.menuItems objectAtIndex:i]; NSRange r = [[thisItem.jsonVars objectForKey:@"titleText"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; if(r.location != NSNotFound){ //if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; //} } } for(int i = 0; i < [self.menuItems count]; i++){ BT_item *thisItem = [self.menuItems objectAtIndex:i]; NSRange r = [[thisItem.jsonVars objectForKey:@"keywordSearch"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; if(r.location != NSNotFound){ //if(r.location == 0){ [self.filteredMenuItems addObject:thisItem]; //} } } }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/25/13 04:39 AM (12 years ago)
Sorry - I'm doing this from my phone! Anyway, try this... //search on every character... if([searchBox.text length] > 0){ //loop through items in menu data... for(int i = 0; i < [self.menuItems count]; i++){ BT_item *thisItem = [self.menuItems objectAtIndex:i]; NSRange r = [[thisItem.jsonVars objectForKey:@"titleText"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; NSRange r2 = [[thisItem.jsonVars objectForKey:@"keywordSearch"] rangeOfString:searchBox.text options:NSCaseInsensitiveSearch]; if(r.location != NSNotFound || r2.location != NSNotFound){ [self.filteredMenuItems addObject:thisItem]; } } }
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.