4

Hibernate search default infinispan configuration store indexes in memory,you have to reindex everything once you shutdown application.

I read infinispan document, there is a way to store index into a infinispan file store. After I do googling around and around, I still don't know how to configure it.

王子1986
  • 3,019
  • 4
  • 31
  • 43

1 Answers1

5

You can check Infinispan user guide chapters 5 (Persistence) and 16 (Infinispan as a storage for Lucene indexes). Chapter numbers are from Infinispan 8.2. Hibernate search also provides a "default-hibernatesearch-infinispan.xml" file to start with. You basically need to add persistence to metadata and actual index caches. Here is the one I use for index cache:

    <distributed-cache name="LuceneIndexesData" mode="SYNC" remote-timeout="25000">
        <transaction mode="NONE"/>
        <state-transfer enabled="true" timeout="480000" await-initial-transfer="true"/>
        <indexing index="NONE"/>
        <locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false"/>
        <eviction max-entries="-1" strategy="NONE"/>
        <expiration max-idle="-1"/>
        <persistence passivation="false">
            <jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
                <jdbc:data-source jndi-url="java:comp/env/jdbc/..."/>
                <jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
                    <jdbc:id-column name="ID" type="VARCHAR(255)"/>
                    <jdbc:data-column name="DATA" type="MEDIUMBLOB"/>
                    <jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
                </jdbc:string-keyed-table>
                <property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
                <write-behind/>
            </jdbc:string-keyed-jdbc-store>
        </persistence>
    </distributed-cache>

This example uses JDBC because it works on a dynamic cluster. You need to replace "jdbc:string-keyed=jdbc-store" with a "file-store" if you want to store the index a file.

berserk81
  • 216
  • 2
  • 5