簡體   English   中英

iOS 9 Core Spotlight搜索不適用於某些字符串CSSearchableItemAttributeSet

[英]ios 9 core spotlight search not working for certain strings CSSearchableItemAttributeSet

我已經在iPhone應用程序中成功(某種程度上)實現了聚光燈索引編制,但是某些搜索字符串似乎無法被搜索到。

我將每個CSSearchableItemAttributeSet創建為kUTTypeText類型,並將顯示名稱設置為“ D0010”。 我還將關鍵字也設置為也包括“ D0010”。 (有幾百個數字遞增,例如D0011,D0012 ...)

該應用程序已成功完成索引編制,沒有錯誤。

當我進入聚光燈搜索並輸入“ D0”時,我得到三個左右的結果,因為繼續輸入“ D001”時,我沒有結果。

有趣的是,如果我輸入“ 0010”,我將得到准確的結果!

有誰知道發生了什么事嗎?

下面的部分目標C代碼。

attributeSet.displayName = [[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]];

    attributeSet.title = [[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]];
    //Sounds similar to displayName but is not displayed to user

    attributeSet.contentDescription = [[NSString alloc] initWithFormat:@"%@", [dataflow flowDescription]];

    attributeSet.keywords = @[[[NSString alloc] initWithFormat:@"%@", [dataflow flowCounter]],[[NSString alloc] initWithFormat:@"D%@", [dataflow flowNumber]],[dataflow flowCounter], attributeSet.displayName, attributeSet.contentDescription,[dataflow flowNumber],[dataflow flowCounter] ];



    CSSearchableItem *item1 = [[CSSearchableItem alloc] initWithUniqueIdentifier:[[NSString alloc] initWithFormat:@"DTC_%@", [dataflow flowNumber]] domainIdentifier:@"com.utiligroup" attributeSet:attributeSet];

........

    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:[self.spotlightsearch copy]
                                               completionHandler: ^(NSError * __nullable error)  {
    if (error != nil ){
        NSLog(@"Error");
    }
    else {
        NSLog(@"dataflows added ");

站下來,我知道添加indexSearchableItems僅標記要索引的項目(即使成功完成返回處理程序時也是如此),但我不知道ios將它們索引多少時間。

1天后,現在可以搜索所有項目。

所以基本上,這只需要一些時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM