With the following steps, you can continue to create an ObjectGrid with one map and an index, along with a schema for the map. Then you can insert an object into the cache and later retrieve it using a simple query.
Application.java // Create an index HashIndex idx= new HashIndex(); idx.setName("theItemName"); idx.setAttributeName("itemName"); idx.setRangeIndex(true); idx.setFieldAccessAttribute(true); orderBMap.addMapIndexPlugin(idx); }
When a query runs that filters on the itemName field, the query engine will automatically use the index when there. This allows the query to run much faster and a map scan is not needed. The next step demonstrates how an index can be used to optimize the query.