🔍 Code Extractor

class QueryProperty

Maturity: 46

A class representing a name-value pair for storing additional or custom properties for SharePoint search queries.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/property.py
Lines:
5 - 19
Complexity:
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

    A class representing a typed property value container for SharePoint Client Search Query operations, where only one property type should be set at a time based on the QueryPropertyValueTypeIndex.

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

    Represents a search query object that encapsulates search terms and optional query templates for SharePoint/Office365 search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/query.py
  • class QueryRoutingInfo 64.6% similar

    A data class representing query routing information for SharePoint search operations, containing query state and search endpoints.

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

    A class representing expanded query parameters for Microsoft Office Server Search REST API, inheriting from ClientValue to provide serialization capabilities.

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

    A data class representing query configuration for a SharePoint local farm, encapsulating query context, parameters, routing information, and search endpoints.

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