🔍 Code Extractor

class QuerySuggestionResults

Maturity: 48

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

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/suggestion_results.py
Lines:
15 - 33
Complexity:
moderate

Purpose

QuerySuggestionResults serves as a data transfer object (DTO) for SharePoint search query suggestions. It encapsulates multiple types of suggestions returned from SharePoint search queries: people name suggestions, personal result suggestions, popular result suggestions, and query suggestions. This 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 QuerySuggestionResults(ClientValue):
    """
    The QuerySuggestionResults complex type is a container for arrays of query suggestions, people name suggestions,
    and personal result suggestions.
    """

    def __init__(self, people_names=None):
        """
        :param list[str] people_names: People names suggested for the user query. MUST be null if
            ShowPeopleNameSuggestions in properties input element is set to false.
        """
        self.PeopleNames = StringCollection(people_names)
        self.PersonalResults = ClientValueCollection(PersonalResultSuggestion)
        self.PopularResults = ClientValueCollection(PersonalResultSuggestion)
        self.Queries = ClientValueCollection(QuerySuggestionQuery)

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

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

people_names: Optional list of strings containing people names suggested for the user query. Should be set to None if ShowPeopleNameSuggestions in the properties input element is set to false. When provided, it will be converted to a StringCollection for proper serialization.

Return Value

Instantiation returns a QuerySuggestionResults object with four initialized attributes: PeopleNames (StringCollection), PersonalResults (ClientValueCollection of PersonalResultSuggestion), PopularResults (ClientValueCollection of PersonalResultSuggestion), and Queries (ClientValueCollection of QuerySuggestionQuery). The entity_type_name property returns the string 'Microsoft.SharePoint.Client.Search.Query.QuerySuggestionResults' for proper type identification in SharePoint API interactions.

Class Interface

Methods

__init__(self, people_names=None)

Purpose: Initializes a QuerySuggestionResults instance with optional people names and empty collections for other suggestion types

Parameters:

  • people_names: Optional list of strings containing people names suggested for the user query. Defaults to None.

Returns: None (constructor)

@property entity_type_name(self) -> str property

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

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

Attributes

Name Type Description Scope
PeopleNames StringCollection Collection of people names suggested for the user query. Initialized from the people_names parameter passed to __init__. instance
PersonalResults ClientValueCollection[PersonalResultSuggestion] Collection of personal result suggestions for the user query. Initialized as an empty collection. instance
PopularResults ClientValueCollection[PersonalResultSuggestion] Collection of popular result suggestions for the user query. Initialized as an empty collection. instance
Queries ClientValueCollection[QuerySuggestionQuery] Collection of query suggestions for the user query. Initialized as an empty collection. instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.runtime.types.collections import StringCollection
from office365.sharepoint.search.query.personal_result_suggestion import PersonalResultSuggestion
from office365.sharepoint.search.query.query_suggestion_query import QuerySuggestionQuery

Usage Example

from office365.sharepoint.search.query.query_suggestion_results import QuerySuggestionResults
from office365.sharepoint.search.query.personal_result_suggestion import PersonalResultSuggestion
from office365.sharepoint.search.query.query_suggestion_query import QuerySuggestionQuery

# Create instance with people names
suggestions = QuerySuggestionResults(people_names=['John Doe', 'Jane Smith'])

# Access people names
print(suggestions.PeopleNames)

# Add personal results
personal_result = PersonalResultSuggestion()
suggestions.PersonalResults.add(personal_result)

# Add query suggestions
query_suggestion = QuerySuggestionQuery()
suggestions.Queries.add(query_suggestion)

# Get entity type name for API serialization
entity_type = suggestions.entity_type_name
print(entity_type)  # 'Microsoft.SharePoint.Client.Search.Query.QuerySuggestionResults'

Best Practices

  • Always set people_names to None if ShowPeopleNameSuggestions is false in the query properties to maintain consistency with SharePoint API expectations
  • Use the provided collection types (StringCollection, ClientValueCollection) rather than plain Python lists to ensure proper serialization with SharePoint API
  • Access the entity_type_name property when serializing this object for SharePoint API requests to ensure proper type identification
  • This class is typically instantiated by the Office365 library when deserializing SharePoint search responses, rather than being manually created by users
  • The class is immutable in structure (attributes are set in __init__), but the collections themselves are mutable and can be modified after instantiation
  • When working with PersonalResults and PopularResults, ensure you're using PersonalResultSuggestion objects
  • When working with Queries, ensure you're using QuerySuggestionQuery objects

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class QuerySuggestionQuery 82.1% 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 PersonalResultSuggestion 79.1% similar

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

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

    A class representing the results of a SharePoint query auto-completion operation, containing execution metrics, correlation information, and a collection of query suggestions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/auto_completion_results.py
  • class TenantCustomQuerySuggestions 72.4% 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
  • class QueryAutoCompletion 72.1% similar

    A class representing query auto-completion results from SharePoint Search, containing matched results from a specific source with associated query text and relevance score.

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