Manage your Searches

Below, you can check how to persist, manage and share the searches you create in Bigdata.

Retrieve Searches

Subsequently, you can get the search by its ID or obtain a list of all your saved searches. These methods return instances of the same type, Search, and a list of searches, respectively. You can use them directly to perform searches or retrieve co-mentions. For example:

searches = bigdata.search.list()
s = searches[0]
# or
s = bigdata.search.get("<the_search_id>")

for result in s.limit_documents(10):
    print(result)

The Search object has the following attributes:

  • id: The unique identifier of the search, a 32-character hexadecimal string. This is only set if the search has been saved.

  • name: The name of the search. This is only set if the search has been saved.

  • query: The query object that represents the search criteria. You will typically never access this attribute directly.

  • company_shared_permission: SharePermission value that represents the share status of this saved search within the company. The only valid values are SharePermission.READ, if the search is currently shared with the company, or None if it’s not shared or the search has not even been saved. See the section Sharing Searches for more details.

Sharing Searches

Searches can be shared with everyone else in the company. Once shared, those users will see the search in their list of saved searches and perform searches based on it, although they won’t be able to modify it. To share a search, you can use the share_with_company method on the search object. For example:

s = bigdata.search.get("<the_search_id>")
s.share_with_company()

Note that you must save a search before sharing it. Attempting to share an unsaved search will raise an exception.

s = bigdata.search.new(query=(Entity("228D42") | Keyword("tesla")))
s.save("My shared search")
s.share_with_company()

After sharing, the company_shared_permission attribute of the search object will be set to SharePermission.READ. To share all searches, you can iterate through them:

searches = bigdata.search.list()
for search in searches:
    if search.company_shared_permission is None:
        print(f"Sharing search {search.name}")
        search.share_with_company()
    else:
        print(f"Search {search.name} is already shared")

To unshare a search, use the unshare_with_company method:

from bigdata_client.models.search import SharePermission

searches = bigdata.search.list()
for search in searches:
    if search.company_shared_permission is SharePermission.READ:
        print(f"Unsharing search {search.name}")
        search.unshare_with_company()
    else:
        print(f"Search {search.name} is not shared")

Warning

If a shared search includes one or more private watchlists, those watchlists will be automatically shared with the company. However, if you unshare a search that contains a watchlist, the watchlist will not be automatically unshared.

Delete Searches

Finally, you can delete the search either by calling the delete method on the search object if you have it, or by calling the delete method on the bigdata.search object with the search ID as an argument if you don’t have the search object. For example:

s.delete()
# or if you don't have the search object but know the ID:
bigdata.search.delete("<the_search_id>")