Alachisoft NCache 4.1 - Online Documentation

Indexing Searchable Attributes in Java

NCache requires all searchable attributes to be indexed. This is because, without indexing, it would have to traverse entire cache in order to find items. That could be a very costly operation with potential of slowing down the entire cache.
NCache provides its own indexing mechanism. You can identify objects in Java assemblies that you want to index. NCache uses Java Reflection to extract data from the indexed attributes and builds its internal index. Then, when you query the cache with cache.searchCQ() and cache.searchEntriesCQ(), NCache uses these indexes to quickly find out the desired objects and returns them to you.
Defining Indexes
NCache Manager provides a user friendly interface for defining indexes. Following example demonstrates procedure of defining indexes on attributes.
Suppose that cache contains Person object where the definition of Person is as below:
public class Person implements Serializable
    public String CustomerID;
    public int Age;
    public Person(String id, int age) {
        this.CustomerID = id;
        this.Age = age;
Follow these steps to define indexes for the attributes of Person:
  • Stop the Cache if it is running.
  • From the tabbed view, select 'Query Indexes' tab as shown in the figure below.
  • Click 'Add' button from the Query Indexes tab, you'll see the 'Select Query Indices' dialog. Click 'Browse' button to add assembly which contains the definition of the Person.
  • From the list of 'Selected Assemblies', select Person class and add it to the List of selected Classes using 'Add Class' button.
  • From the 'Select Query Indexes' dialog, mark the attribute(s) of the Person class that you want to be indexed.
  • Press 'OK' button to complete the process.
  • Following screen appears, showing the attributes selected for the indexing.
See Also

Copyright © 2005-2012 Alachisoft. All rights reserved.