Latest 0.0.1
License MIT
Platforms ios 8.0, osx 10.9

Parsing search string and generate predicates or filtering blocks from it.

Current framework allows to use logical operators with search (like SearchKit). But only you don’t need to generate Index file for using it.

Goal of this framework is generating one NSPredicate, closure, another filtering entities for using them for searching in array, database or any other sources.

Default entities supports AND, &, OR, |, NOT, ! operators, but you can create custom operators yourself.

Default query operators (from highest to lowest precedence):

Operator Meaning
NOT, ! Boolean NOT.
AND, &, <space> Boolean AND. The character represents a Boolean operator when there are terms to both sides of the character. In this case, represents a Boolean AND by default, or a Boolean OR if specified by .spaceMeansOR option.
OR, | Boolean inclusive OR.


iOS (Generating blocks for using array.filter(_:)) and Mac (generating NSPredicate for using with CoreData)

SearchQueryParser SearchQueryParser


It’s pretty easy! You just need to create builder and define predicate/block for one token(small part of search string), after it you can generate predicates/blocks from any string.

Example with blocks:

import SearchQueryParser

let builder = DefaultFilterBlockBuilder<Item>(options: .caseInsensitive, valuePredicate: { str in
    return { $0.searchString.lowercased().contains(str.lowercased()) }

let filterBlock = searchText)
filteredItems = array.filter(filterBlock ?? {_ in true})

Example with NSPredicate:

import SearchQueryParser

let builder = DefaultPredicateBuilder() { NSPredicate(format: "(name LIKE %@) OR (job LIKE %@)", $0, $0) }
self.predicate = searchField.stringValue)

Latest podspec

    "name": "SearchQueryParser",
    "version": "0.0.1",
    "summary": "Parsing search string with logical operators (AND, OR, NOT) and generates predicate from it.",
    "description": "Current framework allows to use logical operators with search (like SearchKit). But only you don't need to generate Index file for using it.nThis framework generates NSPredicate or filtering block by default, but you can write another builder yourself.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Alex Severyanov": "[email protected]"
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    "source": {
        "git": "",
        "tag": "0.0.1"
    "source_files": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This