Search API to have priority for CSSearchableItemAttributeSet

82 views Asked by At

I can create CSSearchableItemAttributeSet like this.

And for example, if I search SQ2,

my result are like this.

SQ212
SQ222
SQ214

Is it possible to give priority to SQ214 when user search SQ2 (i.e Show SQ214 first)?

When I index indexSearchableItems, I will not know whether SQ214 come first or I will not know whether it have SQ214. But if it have, I want to show that first.

- (void)setUpForCityOrAirLineName:(NSString *)cityOrAirline

{

    CSSearchableItemAttributeSet * attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString*)kUTTypeItem];


  attributeSet.title = [NSString stringWithFormat:@"%@",cityOrAirline];


  attributeSet.keywords = @[cityOrAirline];


  CSSearchableItem * item = [[CSSearchableItem alloc] initWithUniqueIdentifier:[NSString stringWithFormat:@"%@///%@",CITY_OR_AIRLINE, cityOrAirline] domainIdentifier:[NSBundle mainBundle].bundleIdentifier attributeSet:attributeSet];


  [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler: ^(NSError * __nullable error) {

  }];

}
0

There are 0 answers