Welcome to the documentation for Haystack!
About Haystack
Haystack is a powerful search framework for iOS and macOS that makes it easy to implement advanced search functionality in your apps. With Haystack, you can quickly integrate powerful features such as fuzzy search, geo-search, sorting, filtering, and more.
Key Features
- Fuzzy search: Perform search queries with typo tolerance and approximate matching.
- Geo-search: Enable location-based searching to find nearby items.
- Sorting: Sort search results based on specific criteria.
- Filtering: Apply filters to narrow down search results based on specific conditions.
- Pagination: Implement pagination to efficiently handle large data sets.
- Weighted attributes: Rank search results based on the importance of specific attributes.
- Highlighting: Display search terms in the search results for easy visibility.
Getting Started
To start using Haystack, you’ll need to install it via Cocoapods. Make sure you have Cocoapods installed on your system, then add the following line to your Podfile:
pod 'Haystack'
After updating your Podfile, run the command:
$ pod install
Usage
Installation
To install Haystack, follow the steps below:
- Install Cocoapods on your system if you haven’t already.
- Create a new Xcode project or open an existing project.
- Open the Terminal, navigate to your project directory, and run the command
pod init
. - Edit the generated Podfile and add the line
pod 'Haystack'
to the desired target. - Save the Podfile and run the command
pod install
. - Open the project workspace file (.xcworkspace) in Xcode.
Integration
Once you have Haystack installed, you can start integrating it into your app. Here are the basic steps:
- Import the Haystack module into your source file:
import Haystack
- Create an instance of
HaystackIndex
with the desired configuration:
let index = HaystackIndex(withConfig: HaystackConfig(...))
- Add and index your data:
index.add(items: [Item1, Item2, ...])
- Perform a search:
let results = index.search(query: "search term")
Guides
Fuzzy Search
Learn how to use fuzzy search to provide typo-tolerant and approximate search functionality in your app using Haystack.
Geo-search
Explore how to enable location-based searching and find nearby items using Haystack’s geo-search capabilities.
Sorting
Get to know how to implement sorting functionality in your search results using Haystack.
Filtering
Discover how to apply filters to narrow down search results based on specific conditions when using Haystack.
Pagination
Learn how to handle large data sets efficiently by implementing pagination in your Haystack search results.
Weighted Attributes
Understand how to rank search results based on the importance of specific attributes using Haystack’s weighted attribute feature.
Highlighting
Find out how to highlight search terms in the search results to improve visibility and user experience with Haystack.
Conclusion
Congratulations! You now have a detailed overview of Haystack and how to integrate it into your iOS or macOS app. The provided guides will help you harness the full power of Haystack’s advanced search functionality. Happy searching!