스트리밍은 대부분의 브라우저와
Developer 앱에서 사용할 수 있습니다.
-
Core Spotlight로 시맨틱 검색 지원하기
Core Spotlight를 사용하여 앱에서 시맨틱 검색 결과를 제공하는 방법을 알아보세요. 사용자가 자연어를 사용하여 항목을 검색할 수 있도록 앱의 콘텐츠를 비공개 온디바이스 인덱스에서 사용하는 방법을 확인해 보세요. 인덱싱 활동의 스케줄을 지정하여 앱의 성능을 최적화하는 방법도 공유합니다. 이 세션을 최대한 활용하려면 먼저 Apple Developer 웹사이트의 Core Spotlight 문서를 살펴보는 것이 좋습니다.
챕터
- 0:00 - Introduction
- 1:37 - Searchable content
- 5:05 - Demo: Creating an index delegate extension
- 6:56 - Results and suggestions
- 9:18 - Ranking
- 10:17 - Wrap-up
리소스
관련 비디오
WWDC24
WWDC21
-
다운로드Array
-
-
2:14 - Creating CSSearchableItem
// Creating searchable items for donation let item = CSSearchableItem(uniqueIdentifier: uniqueIdentifier, domainIdentifier: domainIdentifier, attributeSet: attributeSet)
-
2:28 - Creating CSSearchableAttributeSet
// Creating searchable content for donation let attributeSet = CSSearchableItemAttributeSet(contentType: UTType.text) attributeSet.contentType = UTType.text.identifier
-
2:40 - Searchable items with type
// Searchable items with text attributeSet.title attributeSet.textContent // Searchable items with media attributeSet.contentType attributeSet.contentURL // Searchable items with links attributeSet.contentURL attributeSet.relatedUniqueIdentifier
-
3:31 - Batch indexing with client state
// Batch indexing with client state let index = CSSearchableIndex(name: "SpotlightSearchSample") index.fetchLastClientState { state, error in if state == nil { index.beginBatch() index.indexSearchableItems(items) index.endIndexBatch(expectedClientState: state, newClientState: newState) { error in } } }
-
3:56 - Avoid overwriting existing attributes
// Make it an update to avoid overwriting existing attributes item.isUpdate = true
-
7:19 - Configure a query
// Configure a query let queryContext = CSUserQueryContext() queryContext.fetchAttributes = ["title", "contentDescription"]
-
7:33 - Ranked results
// Ranked results queryContext.enableRankedResults = true queryContext.maxRankedResultCount = 2
-
7:47 - Suggestions
// Suggestions queryContext.maxSuggestionCount = 4
-
7:55 - Filter queries
// Filter queries queryContext.filterQueries = ["contentTypeTree=\"public.image\""]
-
8:23 - Query for searchable items and suggestions
// Query for searchable items and suggestions let query = CSUserQuery(userQueryString: "windsurfing carmel", userQueryContext: queryContext) for try await element in query.responses { switch(element) { case .item(let item): self.items.append(item) break case .suggestion(let suggestion): self.suggestions.append(suggestion) break } }
-
8:40 - Suggestions
// Suggestions suggestion.localizedAttributedSuggestion
-
8:56 - Preparing for queries
// Preparing for queries CSUserQuery.prepare CSUserQuery.prepareWithProtectionClasses
-
9:50 - Set the lastUsedDate
// Set the lastUsedDate when the user interacts with the item item.attributeSet.lastUsedDate = Date.now item.isUpdate = true
-
10:00 - Interactions with items and suggestions from a query
// Interactions with items and suggestions from a query query.userEngaged(item, visibleItems: visibleItems, interaction: CSUserQuery.UserInteractionKind.select) query.userEngaged(suggestion, visibleSuggestions: visibleSuggestions, interaction: CSUserQuery.UserInteractionKind.select)
-
-
찾고 계신 콘텐츠가 있나요? 위에 주제를 입력하고 원하는 내용을 바로 검색해 보세요.
쿼리를 제출하는 중에 오류가 발생했습니다. 인터넷 연결을 확인하고 다시 시도해 주세요.