hansken_extraction_plugin.api.search_result

This module contains a representation of a search result.

Classes

SearchResult()

Class representing a stream of traces, returned when performing a search request.

class SearchResult[source]

Bases: ABC, Iterable

Class representing a stream of traces, returned when performing a search request.

This result can only be iterated once. Results can be retrieved in three ways:

Treating the result as an iterable:

for trace in result:
    print(trace.name)

Calling .take to process one or more batches of traces:

first_100 = result.take(100)
process_batch(first_100)

Calling .takeone to get a single trace:

first = result.takeone()
second = result.takeone()

print(first.name, second.name)
abstract total_results() int[source]

Return the total number of hits.

Returns:

Total number of hits

takeone() SearchTrace | None[source]

Return a single trace, if this stream is not exhausted.

Returns:

A searchtrace, or None if no trace is available

take(num: int) List[SearchTrace][source]

Return a list containing at most num number of traces, or less if they are not available.

Parameters:

num – Number of traces to take

Returns:

List containing zero or more traces

close()[source]

Close this SearchResult if no more traces are to be retrieved.

Required to keep compatibility with hansken.py.