Configure Query Indexes
Indexes are used in querying for efficiency, and are based on the type of a class. The user may further specify the attributes of the class on which indexes are required. Query Indexes can be configured in the following ways:
Add Query Indexes
Using NCache Manager
Click on the cache name in Cache Explorer to open cache settings.
Go to Query Indexes tab.
Click Add.
Select Query Indices wizard will open. Click Browse to browse for required assembly. Select the assembly.
Assembly and all its classes will be listed in Selected Assemblies section.
Select the required classes by checking the check box and click Add Class button.
List of selected classes along with its attributes will be listed down in List of selected Classes section. Select the attributes you want to add indexes for and click OK.
Note
NCache Manager displays all private members and properties of selected class. Select either private members or properties.
Select Query Indexes wizard will close and selected classes and their attributes will appear in ‘Selected Classes and their attributes’ section of ‘Query Indexes’ tab.
Right click on the cache name in Cache Explorer and select Apply Configuration option.
Using Windows PowerShell
Add-QueryIndex
cmdlet enables the user to add query indexes for the objects to be added in the cache.
The following command adds ProductID, ProductName, Category, Supplier and UnitsAvailable attributes from the class Data.Product in query indexes for demoLocalCache
Add-QueryIndex demoLocalCache -AssemblyPath C:\Data.dll -Class Data.Product -Attributes ProductID$ProductName$Category$UnitsAvailable
Manually Editing NCache Configuration
Important
Make sure the cache is stopped before making any configuration changes.
- Specify the query indexes through config.ncconf by adding the
<query-indexes>
and<query-class>
tag under the<cache-settings>
tag. The following example adds attributes of two classes, Product and Customer, as indexes:
<cache-settings ...>
<query-indexes>
<query-class id="Data.Customer" name="Data.Customer">
<query-attributes id="CustomerName" name="CustomerName" data-type="System.String"/>
<query-attributes id="CustomerID" name="CustomerID" data-type="System.Int32"/>
</query-class>
<query-class id="Data.Product" name="Data.Product">
<query-attributes id="ProductName" name="ProductName" data-type="System.String"/>
<query-attributes id="ProductID" name="ProductID" data-type="System.Int32"/>
<query-attributes id="Category" name="Category" data-type="System.String"/>
<query-attributes id="UnitsAvailable" name="UnitsAvailable" data-type="System.Int32"/>
</query-class>
</query-indexes>
</cache-settings>
- Once changes are made, start the cache and restart NCache service.
Removing Query Indexes
Pre-defined query indexes can be removed by the user using the following steps.
Using NCache Manager
Select the Cache name from Cache Explorer for which query indexing is to be removed.
Go to the Query Indexes tab.
Select the Indexes to be removed by checking the box and select Remove.
Using Windows PowerShell
Remove-QueryIndex
cmdlet enables the user to remove pre-defined query indexes
for the objects to be added in the cache.
The following command removes query indexing for the class Customers using default port 8250.
Remove-QueryIndex -CacheName demoClusteredCache -Class Data.Customer
See Also
Create a Cache
Remove Cache
Remove Server Node
Add Test Data