File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -746,6 +746,20 @@ open class Query : AbstractQuery {
746746 set { self [ " responseFields " ] = Query . buildJSONArray ( newValue) }
747747 }
748748
749+ /// Maximum number of facet hits to return during a search for facet values.
750+ ///
751+ /// + Note: Does not apply to regular search queries.
752+ ///
753+ /// + Note: For performance reasons, the maximum allowed number of returned values is 100.
754+ /// Any value outside the range [1, 100] will be rejected.
755+ ///
756+ /// + SeeAlso: `Index.searchForFacetValues(...)`
757+ ///
758+ public var maxFacetHits : UInt ? {
759+ get { return Query . parseUInt ( self [ " maxFacetHits " ] ) }
760+ set { self [ " maxFacetHits " ] = Query . buildUInt ( newValue) }
761+ }
762+
749763 // MARK: - Initialization
750764
751765 /// Construct a query with the specified full text query.
@@ -1011,4 +1025,10 @@ open class Query : AbstractQuery {
10111025 get { return AbstractQuery . toNumber ( self . facetingAfterDistinct) }
10121026 set { self . facetingAfterDistinct = newValue? . boolValue }
10131027 }
1028+
1029+ @objc ( maxFacetHits)
1030+ public var z_objc_maxFacetHits : NSNumber ? {
1031+ get { return AbstractQuery . toNumber ( self . maxFacetHits) }
1032+ set { self . maxFacetHits = newValue? . uintValue }
1033+ }
10141034}
Original file line number Diff line number Diff line change @@ -696,4 +696,14 @@ class QueryTests: XCTestCase {
696696 let query2 = Query . parse ( query1. build ( ) )
697697 XCTAssertEqual ( query2. facetingAfterDistinct, true )
698698 }
699+
700+ func test_maxFacetHits( ) {
701+ let query1 = Query ( )
702+ XCTAssertNil ( query1. maxFacetHits)
703+ query1. maxFacetHits = 66
704+ XCTAssertEqual ( query1. maxFacetHits, 66 )
705+ XCTAssertEqual ( query1 [ " maxFacetHits " ] , " 66 " )
706+ let query2 = Query . parse ( query1. build ( ) )
707+ XCTAssertEqual ( query2. maxFacetHits, query1. maxFacetHits)
708+ }
699709}
You can’t perform that action at this time.
0 commit comments