[docs]defnew(self,query:QueryComponent,date_range:Optional[Union[AbsoluteDateRange,RollingDateRange]]=None,sortby:SortBy=SortBy.RELEVANCE,scope:DocumentType=DocumentType.ALL,rerank_threshold:Optional[float]=None,)->Search:""" Creates a new search object that allows you to perform a search on keywords, entities, etc. Example usage: >>> query = Entity("228D42") & Keyword("tesla") # doctest: +SKIP >>> search = bigdata.search.new( ... query, ... date_range=RollingDateRange.LAST_WEEK, ... sortby=SortBy.RELEVANCE, ... scope=DocumentType.ALL ... ) # doctest: +SKIP >>> search.save() # doctest: +SKIP >>> for document in search.limit_documents(100): # doctest: +SKIP >>> print(document) # doctest: +SKIP >>> print(search.get_summary()) # doctest: +SKIP >>> search.delete() # doctest: +SKIP """returnSearch.from_query(self._api,query,date_range=date_range,sortby=sortby,scope=scope,rerank_threshold=rerank_threshold,)
[docs]defget(self,id_,/)->Search:"""Retrieve a saved search by its id."""response=self._api.get_search(id_)returnSearch.from_saved_search_response(self._api,response)
[docs]deflist(self)->list[Search]:"""Retrieve all saved searches for the current user."""list_response=self._api.list_searches()searches=[]forsearchinlist_response.results:try:response=self._api.get_search(search.id)exceptNotImplementedErrorase:print(f"Skipping search {search.id} because it has an unsupported expression type")continuesearches.append(Search.from_saved_search_response(self._api,response))returnsearches
[docs]defdelete(self,id_,/):"""Delete a saved search by its id."""self._api.delete_search(id_)