2.2. Configure Infinispan Query
2.2.1. Configure Indexing Using XML
Indexing can be configured in XML by adding the
<indexing ... />
element to the cache configuration in the Infinispan core configuration file, and optionally pass additional properties in the embedded Lucene-based Query API engine. For example:
<?xml version="1.0" encoding="UTF-8"?> <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd" xmlns="urn:infinispan:config:6.0"> <default> <indexing enabled="true" indexLocalOnly="true"> <properties> <property name="default.directory_provider" value="ram" /> </properties> </indexing> </default> </infinispan>
In this example, the index is stored in memory. As a result, when the relevant nodes shut down the index is lost. This arrangement is ideal for brief demonstration purposes, but in real world applications, use the default (store on file system) or store the index in Red Hat JBoss Data Grid to persist the index.