Class ObjectIndexer
Specialized SearchIndexer used to index Unity Assets. See Unity.QuickSearch.AssetIndexer for a specialized SearchIndexer used to index simple assets and see Unity.QuickSearch.SceneIndexer for an indexer used to index scene and prefabs.
Inherited Members
Namespace: Unity.QuickSearch
Syntax
public abstract class ObjectIndexer : SearchIndexer
Methods
Build()
Build the index into a separate thread.
Declaration
public override void Build()
Overrides
BuildAsync(Int32, Object)
Build Index asynchronously (in a thread).
Declaration
protected abstract IEnumerator BuildAsync(int progressId, object userData = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | progressId | Id to use to report progress. See ReportProgress(Int32, String, Single, Boolean) |
Object | userData | User data pass to the indexing process. |
Returns
Type | Description |
---|---|
IEnumerator | Returns enumerator during the asynchronous build. |
CallCustomIndexers(String, Int32, Object, SerializedObject, Boolean)
Call all the registered custom indexer for an object of a specific type. See CustomObjectIndexerAttribute.
Declaration
protected void CallCustomIndexers(string documentId, int documentIndex, Object obj, SerializedObject so, bool multiLevel = true)
Parameters
Type | Name | Description |
---|---|---|
String | documentId | Document id. |
Int32 | documentIndex | Document where the indexed object was found. |
Object | obj | Object to index. |
SerializedObject | so | SerializedObject representation of obj. |
Boolean | multiLevel | If true, calls all the indexer that would fit the type of the object (all assignable type). If false only check for an indexer registered for the exact type of the Object. |
GetDependencies()
Get all documents that would be indexed.
Declaration
public abstract List<string> GetDependencies()
Returns
Type | Description |
---|---|
List<String> | Returns a list of file paths. |
GetDocumentHash(String)
Compute the hash of a specific document id. Generally a file path.
Declaration
public abstract Hash128 GetDocumentHash(string id)
Parameters
Type | Name | Description |
---|---|---|
String | id | Document id. |
Returns
Type | Description |
---|---|
Hash128 | Returns the hash of this document id. |
GetEntryComponents(String, Int32)
Splits a string into multiple words that will be indexed. It works with paths and UpperCamelCase strings.
Declaration
protected virtual IEnumerable<string> GetEntryComponents(string entry, int documentIndex)
Parameters
Type | Name | Description |
---|---|---|
String | entry | The string to be split. |
Int32 | documentIndex | The document index that will index that entry. |
Returns
Type | Description |
---|---|
IEnumerable<String> | The entry components. |
GetPropertyValue(SerializedProperty, ref Boolean)
Get the property value of a specific property. This will converts the property to either a double or a string.
Declaration
protected object GetPropertyValue(SerializedProperty property, ref bool saveKeyword)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | property | Property to get value from. |
Boolean | saveKeyword | If set to true, this means we need to save the property name in the index. |
Returns
Type | Description |
---|---|
Object | Property value as a double or a string or null if we weren't able to convert it. |
GetRoots()
Get all this indexer root paths.
Declaration
public abstract IEnumerable<string> GetRoots()
Returns
Type | Description |
---|---|
IEnumerable<String> | Returns a list of root paths. |
HasCustomIndexers(Type, Boolean)
Checks if we have a custom indexer for the specified type.
Declaration
protected bool HasCustomIndexers(Type type, bool multiLevel = true)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to lookup |
Boolean | multiLevel | Check for subtypes too. |
Returns
Type | Description |
---|---|
Boolean | True if a custom indexer exists, otherwise false is returned. |
IndexCustomProperties(String, Int32, Object)
Call all the registered custom indexer for a specific object. See CustomObjectIndexerAttribute.
Declaration
protected void IndexCustomProperties(string documentId, int documentIndex, Object obj)
Parameters
Type | Name | Description |
---|---|---|
String | documentId | Document index. |
Int32 | documentIndex | Document where the indexed object was found. |
Object | obj | Object to index. |
IndexDocument(String, Boolean)
Function to override in a concrete SearchIndexer to index the content of a document.
Declaration
public abstract override void IndexDocument(string id, bool checkIfDocumentExists)
Parameters
Type | Name | Description |
---|---|---|
String | id | Path of the document to index. |
Boolean | checkIfDocumentExists | Check if the document actually exists. |
Overrides
IndexNumber(Int32, String, Double)
Add a key-number value pair to the index. The key won't be added with variations. See AddNumber(String, Double, Int32, Int32).
Declaration
public void IndexNumber(int documentIndex, string name, double number)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed value was found. |
String | name | Key used to retrieve the value. |
Double | number | Number value to store in the index. |
IndexObject(Int32, Object, Boolean)
Index all the properties of an object.
Declaration
protected void IndexObject(int documentIndex, Object obj, bool dependencies = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed object was found. |
Object | obj | Object to index. |
Boolean | dependencies | Index dependencies. |
IndexProperty(Int32, String, String, Boolean, Boolean)
Add a property value to the index. A property is specified with a key and a string value. The value will be stored with multiple variations. See AddProperty(String, String, Int32, Boolean, Boolean).
Declaration
public void IndexProperty(int documentIndex, string name, string value, bool saveKeyword, bool exact = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed word was found. |
String | name | Key used to retrieve the value. See AddProperty(String, String, Int32, Boolean, Boolean) |
String | value | Value to add to the index. |
Boolean | saveKeyword | Define if we store this key in the keyword registry of the index. See Unity.QuickSearch.SearchIndexer.GetKeywords. |
Boolean | exact | If exact is true, only the exact match of the value will be stored in the index (not the variations). |
IndexPropertyComponents(Int32, String, String)
Split a value into multiple components.
Declaration
public void IndexPropertyComponents(int documentIndex, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed word was found. |
String | name | Key used to retrieve the value. See AddProperty(String, String, Int32, Boolean, Boolean) |
String | value | Value to add to the index. |
IndexWord(Int32, String, Boolean, Int32)
Add a new word coming from a specific document to the index. The word will be added with multiple variations allowing partial search. See AddWord(String, Int32, Int32).
Declaration
public void IndexWord(int documentIndex, string word, bool exact = false, int scoreModifier = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed word was found. |
String | word | Word to add to the index. |
Boolean | exact | If true, we will store also an exact match entry for this word. |
Int32 | scoreModifier | Modified to apply to the base score for a specific word. |
IndexWord(Int32, String, Int32, Boolean, Int32)
Add a new word coming from a specific document to the index. The word will be added with multiple variations allowing partial search. See AddWord(String, Int32, Int32).
Declaration
public void IndexWord(int documentIndex, string word, int maxVariations, bool exact, int scoreModifier = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed word was found. |
String | word | Word to add to the index. |
Int32 | maxVariations | Maximum number of variations to compute. Cannot be higher than the length of the word. |
Boolean | exact | If true, we will store also an exact match entry for this word. |
Int32 | scoreModifier | Modified to apply to the base score for a specific word. |
IndexWordComponents(Int32, String)
Split a word into multiple components.
Declaration
public void IndexWordComponents(int documentIndex, string word)
Parameters
Type | Name | Description |
---|---|---|
Int32 | documentIndex | Document where the indexed word was found. |
String | word | Word to add to the index. |
ReportProgress(Int32, String, Single, Boolean)
Report progress of indexing.
Declaration
protected void ReportProgress(int progressId, string value, float progressReport, bool finished)
Parameters
Type | Name | Description |
---|---|---|
Int32 | progressId | Progress id. |
String | value | Progress description. |
Single | progressReport | Progress report value (between 0 and 1). |
Boolean | finished | Is the indexing done? |
Search(String, Int32, Int32)
Run a search query in the index.
Declaration
public override IEnumerable<SearchResult> Search(string searchQuery, int maxScore = 2147483647, int patternMatchLimit = 2999)
Parameters
Type | Name | Description |
---|---|---|
String | searchQuery | Search query to look out for. If if matches any of the indexed variations a result will be returned. |
Int32 | maxScore | Maximum score of any matched Search Result. See score. |
Int32 | patternMatchLimit | Maximum number of matched Search Result that can be returned. See SearchResult. |
Returns
Type | Description |
---|---|
IEnumerable<SearchResult> | Returns a collection of Search Result matching the query. |
Overrides
SkipEntry(String, Boolean)
Called when the index is built to see if a specified document needs to be indexed. See skipEntryHandler
Declaration
public override bool SkipEntry(string path, bool checkRoots = false)
Parameters
Type | Name | Description |
---|---|---|
String | path | Path of a document |
Boolean | checkRoots |
Returns
Type | Description |
---|---|
Boolean | Returns true if the document doesn't need to be indexed. |
Overrides
Events
reportProgress
Event that triggers while indexing is happening to report progress. The event signature is
event(int progressId, string value, float progressReport, bool finished).
Declaration
public event Action<int, string, float, bool> reportProgress
Event Type
Type | Description |
---|---|
Action<Int32, String, Single, Boolean> |