ios-How to build an index to implement a local text search engine that allows fault tolerant search?

Source: Internet
Author: User

1. PrefaceImplement a local search engine that allows for fault-tolerant search, which means that search results do not need to match the search keywords exactly. For example, search for "Eric Wang", the search results can include Erica Watts and so on. Search efficiency is very high. Here we need to use the author: Jerome Morissard lib, everyone can go to my github download. Https://github.com/SaupClear/qingchegithubUse of 2.PermissiveResearch2.1. Import the core. h file2.2. We begin to implement text retrieval when the text input control changesThat is, when this proxy method is called each time, we begin to retrieve2.3. Data Warehouse initialization that needs to be retrieved
#pragma mark retrieves the data Warehouse initialization/** *  Retrieve data initialization */-(void) rebuilddatabase{       //////data you need to retrieve in your own code    nsarray *allmenus = Self.mainDelegate.gbdata.objMenu.MenuItemArray;       Add the data object you want to retrieve in your code into the retrieval Data Warehouse, and associate the name       for (Menuitemobject *objmenu in Allmenus) {               ///The first parameter is the object you want to retrieve, obj, The second obj.name for your object (for example, by name)        [[Permissiveresearchdatabase shareddatabase] Addretainedobjet:objmenu forkey:o Bjmenu.displayname];}    }
2.4. Start the search Retrieve ten steps to go
       1. First empty the search result array [self.arraysearchmenu removeallobjects]; 2. Simple processing of text-controlled user-entered characters nsstring *final = [Textfield.text stringbyreplacingcharactersinrange:range withstring:string]          ;       3. Start Search NSLog (@ "Start Search by Matrix");       4. Eliminate all [[Scoringoperationqueue mainqueue] cancelalloperations];       5. Initialize exactscoringoperation *ope = [[Exactscoringoperation alloc] init];       6. The string to retrieve is assigned ope.searchedstring = final; 7. Call retrieve block to return the retrieved results Searchcompletionblock block = ^ (Nsarray *results) {Dispatch_async (dispatch_get_ma In_queue (), ^{//8. Note: Here the uniformly retrieved objects are permissiveobject//You need to retrieve them out really in the permissiveobject.                       Refencedobject Nsmutablearray *permissiveobj = [Nsmutablearray arraywitharray:results];                               9. Remove the data that you need to retrieve and then add the data for the result (Permissiveobject *perobj in permissiveobj) { Menusearchobject *obj=[[menusearchobject Alloc]iNIT];                Menuitemobject *objmenu = Perobj.refencedobject;                               Test log NSLog (@ "%@", objmenu.displayname);                               Obj.menuid=[nsnumber NumberWithInteger:objMenu.menuid.integerValue];   [Self.arraysearchmenu Addobject:obj]; Add Filter Menu Objection}//10. Refreshes the tableview that displays the results of the search [Self.searchtablevi                       EW Reloaddata];                   NSLog (@ "End Search by Matrix");           });          };    Search complete [ope setcustomcompletionblock:block];    Add Operation End. [[Scoringoperationqueue Mainqueue] addoperation:ope];

If there is nothing to understand welcome in the following message, I have time to reply, thank you.Clear Saup
Source:http://www.cnblogs.com/qingche/
This article is copyright to the author and the blog Park is shared, welcome reprint, but must retain this paragraph statement, and in the article page obvious location to give the original text connection.   

ios-How to build an index to implement a local text search engine that allows fault tolerant search?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.