class QueryAutoCompletionMatch
A data class representing a single autocomplete match result from a SharePoint search query, containing alternation text and a key identifier.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/auto_completion_match.py
4 - 14
simple
Purpose
This class serves as a data transfer object (DTO) for SharePoint search query autocompletion results. It inherits from ClientValue, which is part of the Office365 REST API Python client library, and represents one match suggestion that can be returned when performing query autocompletion operations in SharePoint Search. The class encapsulates the alternation text (the suggested completion) and a key identifier for the match.
Source Code
class QueryAutoCompletionMatch(ClientValue):
"""Represents one match in the Source for the Query"""
def __init__(self, alternation=None, key=None):
""" """
self.Alternation = alternation
self.Key = key
@property
def entity_type_name(self):
return "Microsoft.SharePoint.Client.Search.Query.QueryAutoCompletionMatch"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
alternation: The suggested text completion or alternation for the query. This is the actual autocomplete suggestion text that would be displayed to the user. Can be None if not provided during initialization.
key: A unique identifier or key associated with this particular autocomplete match. Used to distinguish between different matches and potentially for tracking or selection purposes. Can be None if not provided during initialization.
Return Value
Instantiation returns a QueryAutoCompletionMatch object with Alternation and Key attributes set to the provided values (or None if not provided). The entity_type_name property returns the string 'Microsoft.SharePoint.Client.Search.Query.QueryAutoCompletionMatch', which identifies this object's type in the SharePoint Client Object Model.
Class Interface
Methods
__init__(self, alternation=None, key=None)
Purpose: Initializes a new QueryAutoCompletionMatch instance with optional alternation text and key identifier
Parameters:
alternation: Optional string representing the autocomplete suggestion text. Defaults to None.key: Optional identifier for this match. Defaults to None.
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the fully qualified entity type name for this object in the SharePoint Client Object Model
Returns: String 'Microsoft.SharePoint.Client.Search.Query.QueryAutoCompletionMatch' identifying the entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Alternation |
str or None | The suggested autocomplete text or alternation for the query. Set during initialization and can be None. | instance |
Key |
str or None | A unique identifier or key associated with this autocomplete match. Set during initialization and can be None. | instance |
Dependencies
office365-rest-python-client
Required Imports
from office365.runtime.client_value import ClientValue
from office365.sharepoint.search.query.query_auto_completion_match import QueryAutoCompletionMatch
Usage Example
from office365.sharepoint.search.query.query_auto_completion_match import QueryAutoCompletionMatch
# Create a new autocomplete match
match = QueryAutoCompletionMatch(
alternation="SharePoint Documentation",
key="doc_001"
)
# Access the attributes
print(f"Suggestion: {match.Alternation}")
print(f"Key: {match.Key}")
print(f"Entity Type: {match.entity_type_name}")
# Create with default values
empty_match = QueryAutoCompletionMatch()
print(f"Empty match alternation: {empty_match.Alternation}") # None
print(f"Empty match key: {empty_match.Key}") # None
Best Practices
- This class is typically instantiated by the Office365 REST API client library when processing search autocomplete responses, rather than being manually created by end users.
- The class is immutable after creation in typical usage - attributes are set during initialization and accessed via direct attribute access.
- When working with multiple matches, they are usually returned as a collection from a parent query autocompletion operation.
- The entity_type_name property should not be modified as it identifies the object type in the SharePoint Client Object Model.
- Both Alternation and Key can be None, so always check for None values before using these attributes in production code.
- This class inherits from ClientValue, which provides serialization capabilities for communication with SharePoint REST APIs.
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class QueryAutoCompletion 88.5% similar
-
class QueryAutoCompletionResults 83.5% similar
-
class QuerySuggestionResults 67.4% similar
-
class QuerySuggestionQuery 66.5% similar
-
class PersonalResultSuggestion 66.0% similar