class QueryProperty
A class representing a name-value pair for storing additional or custom properties for SharePoint search queries.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/property.py
5 - 19
simple
Purpose
QueryProperty is used to encapsulate custom search query properties in SharePoint's search API. It structures data as name-value pairs where the name is a string identifier and the value is a QueryPropertyValue object. This class inherits from ClientValue, making it compatible with SharePoint's client-side object model for serialization and communication with SharePoint services.
Source Code
class QueryProperty(ClientValue):
"""This object stores additional or custom properties for a search query. A QueryProperty is structured
as name-value pairs."""
def __init__(self, name=None, value=QueryPropertyValue()):
"""
:param str name: This property stores the name part of the QueryProperty name-value pair.
:param QueryPropertyValue value: This property stores the value part of the QueryProperty name-value pair.
"""
self.Name = name
self.Value = value
@property
def entity_type_name(self):
return "Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
name: A string representing the name/key part of the property. This identifies the custom property being set for the search query. Can be None if not specified during initialization.
value: A QueryPropertyValue object representing the value part of the property. Defaults to an empty QueryPropertyValue() instance if not provided. This stores the actual data associated with the property name.
Return Value
Instantiation returns a QueryProperty object with Name and Value attributes set according to the provided parameters. The entity_type_name property returns the string 'Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue', which identifies the type in SharePoint's type system.
Class Interface
Methods
__init__(name=None, value=QueryPropertyValue()) -> None
Purpose: Initializes a new QueryProperty instance with a name and value
Parameters:
name: Optional string representing the property name. Defaults to None.value: QueryPropertyValue object representing the property value. Defaults to a new QueryPropertyValue() instance.
Returns: None (constructor)
@property entity_type_name() -> str
property
Purpose: Returns the SharePoint entity type name for this class, used for type identification in the SharePoint client object model
Returns: String 'Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue' representing the SharePoint type identifier
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Name |
str or None | Stores the name/key part of the QueryProperty name-value pair. Set during initialization. | instance |
Value |
QueryPropertyValue | Stores the value part of the QueryProperty name-value pair. Contains the actual data associated with the property name. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.sharepoint.search.query.property_value import QueryPropertyValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.search.query.property_value import QueryPropertyValue
from office365.sharepoint.search.query.property import QueryProperty
# Create a QueryPropertyValue for the value part
property_value = QueryPropertyValue()
# Create a QueryProperty with a name and value
query_prop = QueryProperty(name="CustomProperty", value=property_value)
# Access the name and value
print(query_prop.Name) # Output: CustomProperty
print(query_prop.Value) # Output: QueryPropertyValue instance
# Get the entity type name
print(query_prop.entity_type_name) # Output: Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue
# Create with default value
default_prop = QueryProperty(name="AnotherProperty")
print(default_prop.Name) # Output: AnotherProperty
Best Practices
- Always provide a meaningful name when creating a QueryProperty to identify the custom property clearly
- Ensure the QueryPropertyValue object is properly initialized with the correct data type before passing it to QueryProperty
- Use this class as part of SharePoint search query configuration, typically in collections of properties
- The entity_type_name property is used internally by the SharePoint client library for type identification during serialization
- This class is immutable after creation in typical usage - set Name and Value during instantiation or immediately after
- QueryProperty instances are typically used in arrays or collections when building complex search queries
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class QueryPropertyValue 79.3% similar
-
class SearchQuery 70.8% similar
-
class QueryRoutingInfo 64.6% similar
-
class ExpandedQueryParameters 64.5% similar
-
class QueryConfiguration 64.4% similar