File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
src/commonMain/kotlin/com/algolia/search Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,21 @@ public interface EndpointSearch {
123123 requestOptions : RequestOptions ? = null
124124 ): ResponseSearch
125125
126+ /* *
127+ * Search iteratively through the search response [ResponseSearch.hits] field to find the first response hit tha
128+ * would match against the give [match] function.
129+ * If no object has been found within the first result set, the function
130+ * will perform a new search operation on the next page of results, if any,
131+ * until a matching object is found or the end of results, whichever
132+ * happens first.
133+ * [doNotPaginate] will stop the function at the end of the first page of search results even if no object does
134+ * match.
135+ *
136+ * @param match Predicate to match a given [ResponseSearch.Hit]
137+ * @param query The [Query] used to search.
138+ * @param doNotPaginate To prevent the iteration through pages of results.
139+ * @param requestOptions Configure request locally with [RequestOptions].
140+ */
126141 tailrec suspend fun findFirstObject (
127142 match : (ResponseSearch .Hit ) -> Boolean ,
128143 query : Query = Query (),
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import com.algolia.search.model.settings.Settings
1111import com.algolia.search.serialize.*
1212import kotlinx.serialization.*
1313import kotlinx.serialization.json.JsonElement
14- import kotlinx.serialization.json.JsonLiteral
1514import kotlinx.serialization.json.JsonObject
1615
1716
@@ -274,6 +273,10 @@ public data class ResponseSearch(
274273 public val hierarchicalFacets: Map <Attribute , List <Facet >>
275274 get() = hierarchicalFacetsOrNull!!
276275
276+ /* *
277+ * Returns the position (0-based) within the [hits] result list of the record matching against the given [objectID].
278+ * If the [objectID] is not found, -1 is returned.
279+ */
277280 public fun getObjectIDPosition (objectID : ObjectID ): Int {
278281 return hits.indexOfFirst { it.json.getPrimitiveOrNull(" objectID" )?.content == objectID.raw }
279282 }
You can’t perform that action at this time.
0 commit comments