class CustomResult
A data class representing custom search query results with layout templates and properties for Microsoft Office Server Search REST API.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/custom_result.py
4 - 32
simple
Purpose
CustomResult is a client-side value object that encapsulates search query results with customizable display templates and metadata. It inherits from ClientValue and is designed to work with Microsoft Office Server Search REST API, allowing developers to specify how search results should be grouped, displayed, and titled. The class provides a structured way to handle search result customization including layout templates for both groups and individual items, along with a property bag for additional metadata.
Source Code
class CustomResult(ClientValue):
"""
This contains a list of query results, all of which are of the type specified in TableType.
"""
def __init__(
self,
group_template_id=None,
item_template_id=None,
result_title=None,
properties=None,
):
"""
:param str group_template_id: Specifies the identifier of the layout template that specifies how the results
returned will be arranged.
:param str item_template_id: Specifies the identifier of the layout template that specifies how the result
item will be displayed.
:param str result_title: Specifies the title associated with results for the transformed query by query rule
action. MUST NOT be more than 64 characters in length.
:param dict properties: Specifies a property bag of key value pairs.
"""
self.GroupTemplateId = group_template_id
self.ItemTemplateId = item_template_id
self.Properties = properties
self.ResultTitle = result_title
@property
def entity_type_name(self):
return "Microsoft.Office.Server.Search.REST.CustomResult"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
group_template_id: Optional string identifier specifying the layout template that determines how the collection of results will be arranged/grouped. This controls the visual organization of multiple search results. Defaults to None if not specified.
item_template_id: Optional string identifier specifying the layout template that determines how each individual result item will be displayed. This controls the visual presentation of a single search result. Defaults to None if not specified.
result_title: Optional string specifying the title associated with the transformed query results. This title is applied when query rule actions transform the query. Must not exceed 64 characters in length. Defaults to None if not specified.
properties: Optional dictionary (property bag) containing key-value pairs for additional metadata or configuration options associated with the search results. Allows for extensible custom properties. Defaults to None if not specified.
Return Value
Instantiation returns a CustomResult object with four instance attributes (GroupTemplateId, ItemTemplateId, Properties, ResultTitle) initialized from the constructor parameters. The entity_type_name property returns the string 'Microsoft.Office.Server.Search.REST.CustomResult' which identifies the type in the Microsoft Office Server Search REST API context.
Class Interface
Methods
__init__(self, group_template_id=None, item_template_id=None, result_title=None, properties=None)
Purpose: Initializes a CustomResult instance with search result customization parameters
Parameters:
group_template_id: Optional string identifier for the group layout templateitem_template_id: Optional string identifier for the item layout templateresult_title: Optional string title for the results (max 64 characters)properties: Optional dictionary of additional key-value properties
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the entity type identifier used by Microsoft Office Server Search REST API for serialization and type identification
Returns: String 'Microsoft.Office.Server.Search.REST.CustomResult' representing the entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
GroupTemplateId |
str or None | Stores the identifier of the layout template for arranging result groups | instance |
ItemTemplateId |
str or None | Stores the identifier of the layout template for displaying individual result items | instance |
Properties |
dict or None | Stores a property bag of key-value pairs for additional metadata | instance |
ResultTitle |
str or None | Stores the title associated with the transformed query results (max 64 characters) | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.search.query.custom_result import CustomResult
# Create a custom result with all parameters
custom_result = CustomResult(
group_template_id='group_template_001',
item_template_id='item_template_001',
result_title='Search Results for Documents',
properties={'category': 'documents', 'priority': 'high'}
)
# Access attributes
print(custom_result.GroupTemplateId) # 'group_template_001'
print(custom_result.ResultTitle) # 'Search Results for Documents'
print(custom_result.entity_type_name) # 'Microsoft.Office.Server.Search.REST.CustomResult'
# Create with minimal parameters
minimal_result = CustomResult(result_title='Quick Search')
print(minimal_result.ResultTitle) # 'Quick Search'
print(minimal_result.GroupTemplateId) # None
Best Practices
- Ensure result_title does not exceed 64 characters to comply with API constraints
- Use meaningful template IDs that correspond to actual layout templates configured in your SharePoint/Office 365 environment
- The properties dictionary should contain serializable key-value pairs suitable for REST API transmission
- This class is typically instantiated as part of search query configuration and should be used in conjunction with other Office 365 search API components
- The class is immutable after instantiation in typical usage - attributes are set via constructor and accessed directly
- When using with Office 365 SDK, ensure proper authentication context is established before using CustomResult objects in API calls
- The entity_type_name property is used internally by the Office 365 SDK for serialization and should not be modified
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PromotedResultsOperationsResult 72.5% similar
-
class RefinementResults 71.5% similar
-
class SpecialTermResult 70.9% similar
-
class PersonalResultSuggestion 70.4% similar
-
class SearchResponse 70.3% similar