# IndexProperty

> Adds a property value to the index. A property is specified with a key and a string value.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

## IndexProperty(int, string, string, bool)

Adds a property value to the index. A property is specified with a key and a string value.

```csharp
public void IndexProperty(int documentIndex, string name, string value, bool saveKeyword)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed word was found.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Key used to retrieve the value.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Value to add to the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Define if we store this key in the keyword registry of the index.

### Remarks

The following example indexes a new boolean property named `testismobilefriendly` that will be used to search textures that match `testismobilefriendly=true` or `testismobilefriendly=false`.

```csharp
[CustomObjectIndexer(typeof(Texture2D))]
static void IndexMobileFriendlyTexture(CustomObjectIndexerTarget target, ObjectIndexer indexer)
{
    var texture = target.target as Texture2D;
    if (texture == null)
        return;

    bool isMobileFriendly = texture.width < 64 && texture.height < 64;

    // Important Notes:
    // Use IndexProperty<PropertyType, PropertyTypeOwner> to ensure testismobilefriendly is available in the QueryBuilder.
    // Prefix propertyname with something (ex: PropertyOwnerType) to have a unique property name that won't clash in the QueryBuilder
    // saveKeyword: false -> Ensure the index keyword list won't be polluted with the keyword VALUES.
    indexer.IndexProperty<bool, Texture2D>(target.documentIndex, "Texture2D.testismobilefriendly", isMobileFriendly.ToString(), saveKeyword: false);
}
```

See [SearchIndexer.AddProperty](/engine/6000.7/script-reference/unityeditor/search/searchindexer/addproperty.md) for more information and examples about indexing properties.

## IndexProperty(int, string, string, bool, bool)

Adds a property value to the index. A property is specified with a key and a string value.

> **Warning:**
>
> **Deprecated.** IndexProperty with variations is no longer supported. Variations are handled automatically internally. Please use IndexProperty(int documentIndex, string name, string value, bool saveKeyword)

```csharp
public void IndexProperty(int documentIndex, string name, string value, bool saveKeyword, bool exact)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed word was found.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Key used to retrieve the value.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Value to add to the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Define whether to store this key in the keyword registry of the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If exact is true, store only the exact match of the value (not variations) in the index.

## IndexProperty\<T, U>(int, string, string)

Adds a property value to the index. A property is specified with a key and a string value.

```csharp
public void IndexProperty<TProperty, TPropertyOwner>(int documentIndex, string propertyName, string value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed word was found.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the property to use as the key to the index entry.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Value to add to the index.

### Remarks

The following example indexes a new boolean property named `testismobilefriendly` that will be used to search textures that match `testismobilefriendly=true` or `testismobilefriendly=false`.

```csharp
[CustomObjectIndexer(typeof(Texture2D))]
static void IndexMobileFriendlyTexture(CustomObjectIndexerTarget target, ObjectIndexer indexer)
{
    var texture = target.target as Texture2D;
    if (texture == null)
        return;

    bool isMobileFriendly = texture.width < 64 && texture.height < 64;

    // Important Notes:
    // Use IndexProperty<PropertyType, PropertyTypeOwner> to ensure testismobilefriendly is available in the QueryBuilder.
    // Prefix propertyname with something (ex: PropertyOwnerType) to have a unique property name that won't clash in the QueryBuilder
    // saveKeyword: false -> Ensure the index keyword list won't be polluted with the keyword VALUES.
    indexer.IndexProperty<bool, Texture2D>(target.documentIndex, "Texture2D.testismobilefriendly", isMobileFriendly.ToString(), saveKeyword: false);
}
```

See [SearchIndexer.AddProperty](/engine/6000.7/script-reference/unityeditor/search/searchindexer/addproperty.md) for more information and examples about indexing properties.

## IndexProperty\<T, U>(int, string, string, bool)

Adds a property value to the index. A property is specified with a key and a string value.

```csharp
public void IndexProperty<TProperty, TPropertyOwner>(int documentIndex, string propertyName, string value, bool saveKeyword)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed word was found.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the property to use as the key to the index entry.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Value to add to the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Define if we store this key in the keyword registry of the index.

### Remarks

The following example indexes a new boolean property named `testismobilefriendly` that will be used to search textures that match `testismobilefriendly=true` or `testismobilefriendly=false`.

```csharp
[CustomObjectIndexer(typeof(Texture2D))]
static void IndexMobileFriendlyTexture(CustomObjectIndexerTarget target, ObjectIndexer indexer)
{
    var texture = target.target as Texture2D;
    if (texture == null)
        return;

    bool isMobileFriendly = texture.width < 64 && texture.height < 64;

    // Important Notes:
    // Use IndexProperty<PropertyType, PropertyTypeOwner> to ensure testismobilefriendly is available in the QueryBuilder.
    // Prefix propertyname with something (ex: PropertyOwnerType) to have a unique property name that won't clash in the QueryBuilder
    // saveKeyword: false -> Ensure the index keyword list won't be polluted with the keyword VALUES.
    indexer.IndexProperty<bool, Texture2D>(target.documentIndex, "Texture2D.testismobilefriendly", isMobileFriendly.ToString(), saveKeyword: false);
}
```

See [SearchIndexer.AddProperty](/engine/6000.7/script-reference/unityeditor/search/searchindexer/addproperty.md) for more information and examples about indexing properties.

## IndexProperty\<T, U>(int, string, string, bool, bool)

Adds a property value to the index. A property is specified with a key and a string value.

> **Warning:**
>
> **Deprecated.** IndexProperty with variations is no longer supported. Variations are handled automatically internally. Please use IndexProperty(int documentIndex, string name, string value, bool saveKeyword)

```csharp
public void IndexProperty<TProperty, TPropertyOwner>(int documentIndex, string name, string value, bool saveKeyword, bool exact)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed word was found.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Key used to retrieve the value.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Value to add to the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Define whether to store this key in the keyword registry of the index.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If exact is true, store only the exact match of the value (not variations) in the index.
