# Read(Stream, bool)

> Reads a stream and populates the index from it.

## Definition

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

> **Warning:**
>
> **Deprecated.** This method is no longer supported. The content of the indexer is automatically saved on disk.

```csharp
public bool Read(Stream stream, bool checkVersionOnly)
```

### Parameters

**** (\[Stream]\(https\://learn.microsoft.com/dotnet/api/system.io.stream)): The stream to read the index from.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, verifies the version of the index.

### Returns

| Type                                                          | Description                                                 |
| ------------------------------------------------------------- | ----------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns false if the version of the index is not supported. |

### Examples

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

static class Example_SearchIndexer_Read
{
    [MenuItem("Examples/SearchIndexer/Read")]
    public static void Run()
    {
        var si = new SearchIndexer("SearchIndexerExample", FileUtil.GetUniqueTempPathInProject());
        si.Start();
        si.AddDocument("document 1");
        si.AddDocument("document 2");
        si.Finish(() =>
        {
            File.WriteAllBytes("Temp/Read.index", si.SaveBytes());
            // Dispose of the SearchIndexer when you are done with it.
            si.Dispose();

            // Stream the index from disk but only check if the stream is valid.
            using (var fileStream = new FileStream("Temp/Read.index", FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using var copyIndex = new SearchIndexer("SearchIndexerExample2", FileUtil.GetUniqueTempPathInProject());
                Debug.Assert(copyIndex.Read(fileStream, checkVersionOnly: true));
            }

            // Completely stream the index from disk.
            using (var fileStream = new FileStream("Temp/Read.index", FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using var copyIndex = new SearchIndexer("SearchIndexerExample", FileUtil.GetUniqueTempPathInProject());
                Debug.Assert(copyIndex.Read(fileStream, checkVersionOnly: false));
                Debug.Assert(copyIndex.GetDocument(0).id == "document 1");
            }
        });
    }
}
```
