🔍 Code Extractor

class PersonalResultSuggestion

Maturity: 36

A data class representing a personal search result suggestion from SharePoint Search, containing metadata about suggested results including title, URL, and best bet status.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/personal_result_suggestion.py
Lines:
4 - 22
Complexity:
simple

Purpose

This class encapsulates personal search result suggestions returned from SharePoint Search queries. It stores information about suggested results including the title (both plain and highlighted with matching tokens), URL, and whether the result is marked as a 'best bet'. The class inherits from ClientValue, making it compatible with the Office365 REST API client framework for serialization and deserialization of SharePoint search results.

Source Code

class PersonalResultSuggestion(ClientValue):
    def __init__(self, highlighted_title=None, is_best_bet=None, title=None, url=None):
        """
        The PersonalResultSuggestion complex type contains a personal search result suggestion.

        :param str highlighted_title: Title of the suggested result. Tokens that match the corresponding personal
             query MUST be surrounded by the <c0></c0> tags.
        :param bool is_best_bet: MUST be true if the suggested result was a best bet for the query.
        :param str title: Title of the suggested result.
        :param str url: URL of the suggested result.
        """
        self.HighlightedTitle = highlighted_title
        self.IsBestBet = is_best_bet
        self.Title = title
        self.Url = url

    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Client.Search.Query.PersonalResultSuggestion"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

highlighted_title: The title of the suggested result with matching query tokens surrounded by <c0></c0> tags for highlighting purposes. This allows UI components to visually emphasize matching terms. Can be None if no highlighting is available.

is_best_bet: A boolean flag indicating whether this result was marked as a 'best bet' for the search query. Best bets are curated results that administrators configure to appear prominently for specific queries. Can be None if not specified.

title: The plain text title of the suggested search result without any markup or highlighting. Can be None if not provided.

url: The URL string pointing to the suggested result resource. This is the destination link users would navigate to when selecting this suggestion. Can be None if not available.

Return Value

Instantiation returns a PersonalResultSuggestion object with four instance attributes (HighlightedTitle, IsBestBet, Title, Url) set to the provided parameter values. The entity_type_name property returns the string 'Microsoft.SharePoint.Client.Search.Query.PersonalResultSuggestion', which is used for type identification in the SharePoint REST API.

Class Interface

Methods

__init__(self, highlighted_title=None, is_best_bet=None, title=None, url=None)

Purpose: Initializes a PersonalResultSuggestion instance with search result metadata

Parameters:

  • highlighted_title: Title with matching query tokens surrounded by <c0></c0> tags for highlighting
  • is_best_bet: Boolean indicating if this is a curated best bet result
  • title: Plain text title of the suggested result
  • url: URL string pointing to the result resource

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this class, used for API serialization and type identification

Returns: String 'Microsoft.SharePoint.Client.Search.Query.PersonalResultSuggestion' representing the SharePoint entity type

Attributes

Name Type Description Scope
HighlightedTitle str or None Title of the suggested result with matching query tokens surrounded by <c0></c0> tags for highlighting instance
IsBestBet bool or None Flag indicating whether this result is a curated best bet for the query instance
Title str or None Plain text title of the suggested result without markup instance
Url str or None URL pointing to the suggested result resource instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.client_search_query import PersonalResultSuggestion

# Create a personal result suggestion
suggestion = PersonalResultSuggestion(
    highlighted_title="Project <c0>Report</c0> 2024",
    is_best_bet=True,
    title="Project Report 2024",
    url="https://sharepoint.company.com/sites/projects/report2024.docx"
)

# Access attributes
print(suggestion.Title)  # Output: Project Report 2024
print(suggestion.IsBestBet)  # Output: True
print(suggestion.Url)  # Output: https://sharepoint.company.com/sites/projects/report2024.docx

# Get entity type name for API serialization
print(suggestion.entity_type_name)  # Output: Microsoft.SharePoint.Client.Search.Query.PersonalResultSuggestion

Best Practices

  • This class is primarily a data container and should be instantiated with search result data received from SharePoint Search API responses.
  • All constructor parameters are optional (default to None), allowing partial result data to be represented.
  • The HighlightedTitle should contain <c0></c0> tags around matching query terms for proper UI rendering of highlighted results.
  • The entity_type_name property should not be modified as it's used for proper serialization/deserialization with SharePoint REST API.
  • This class is immutable by design - attributes are set during initialization and typically not modified afterward.
  • When working with search results, check if IsBestBet is True to prioritize or specially display curated results.
  • The class inherits from ClientValue, which provides serialization capabilities for the Office365 REST API client framework.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class QuerySuggestionResults 79.1% similar

    A container class for SharePoint search query suggestions, including people names, personal results, popular results, and query suggestions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/suggestion_results.py
  • class QuerySuggestionQuery 75.4% similar

    A client value class representing a query suggestion query for SharePoint search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/suggestion_results.py
  • class PromotedResultsOperationsResult 73.0% similar

    A data class representing the result of a REST API call to retrieve promoted search results from SharePoint/Office 365.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/promoted_results_operations_result.py
  • class CustomResult 70.4% similar

    A data class representing custom search query results with layout templates and properties for Microsoft Office Server Search REST API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/custom_result.py
  • class TenantCustomQuerySuggestions 70.3% similar

    A client value class representing tenant-level custom query suggestions for SharePoint Search, inheriting from ClientValue base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/tenant_custom_query_suggestions.py
← Back to Browse