# AddNumber(string, double, int, int)

> Adds a key-number value pair to the index. The key won't be added with variations.

## Definition

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

```csharp
public void AddNumber(string key, double value, int score, int documentIndex)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Key used to retrieve the value.**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): Number value to store in the index.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Relevance score of the word.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Document where the indexed value was found.

### Examples

```csharp
using System.Linq;
using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

static class Example_SearchIndexer_AddNumber
{
    [MenuItem("Examples/SearchIndexer/AddNumber")]
    public static void Run()
    {
        var si = new SearchIndexer("SearchIndexerExample", FileUtil.GetUniqueTempPathInProject());
        si.Start();

        // Add some documents and index a power value that can be searched.
        si.AddNumber("power", 4.4, score: 0, si.AddDocument("Weak"));
        si.AddNumber("power", 6.42, score: 0, si.AddDocument("Healthy"));
        si.AddNumber("power", 9.9, score: 0, si.AddDocument("Strong"));

        si.Finish(() =>
        {
            SearchPowerLevels(si);
            // Dispose the SearchIndexer when you are done with it.
            si.Dispose();
        });
    }

    private static void SearchPowerLevels(SearchIndexer si)
    {
        SearchPowerLevel(si, "power<5", 1);
        SearchPowerLevel(si, "power>=6", 2);
    }

    static void SearchPowerLevel(SearchIndexer si, string powerQuery, int expectedCount)
    {
        var results = si.Search(powerQuery).ToList();
        Debug.Assert(results.Count == expectedCount, "Invalid query");
        Debug.Log($"Document with {powerQuery}: {string.Join(", ", results.Select(r => r.id))}");
    }
}
```
