Hibernate SVN: r15397 - branches/Branch_3_2/HibernateExt/tools.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-10-27 06:57:23 -0400 (Mon, 27 Oct 2008)
New Revision: 15397
Modified:
branches/Branch_3_2/HibernateExt/tools/build.xml
Log:
better junit init
Modified: branches/Branch_3_2/HibernateExt/tools/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/build.xml 2008-10-27 10:56:44 UTC (rev 15396)
+++ branches/Branch_3_2/HibernateExt/tools/build.xml 2008-10-27 10:57:23 UTC (rev 15397)
@@ -15,6 +15,8 @@
<import file="../common/common-build.xml"/>
+ <property name="jdbc.driver.jar" location="lib/jdbc/hsqldb.jar"/>
+
<path id="testsrc.path">
<pathelement location="${test.dir}"/>
<pathelement location="src/testsupport"/>
@@ -23,7 +25,7 @@
<path id="junit.moduleclasspath">
<pathelement location="etc"/>
<pathelement location="lib/testlibs/org.eclipse.jdt.core_3.1.0.jar"/>
- <pathelement location="${hibernate-core.jdbc.dir}/hsqldb.jar"/>
+ <pathelement location="${jdbc.driver.jar}"/>
<path refid="testsrc.path"/>
<pathelement location="${java.home}\..\lib\tools.jar"/>
</path>
@@ -37,7 +39,11 @@
</target>
-
+ <target name="junit">
+ <delete dir="testdb" failonerror="yes"/>
+ <antcall target="common-build.junit"/>
+ </target>
+
<target name="compile" depends="common-build.compile">
<copy todir="${classes.dir}">
<fileset dir="${template.dir}"/>
15 years, 6 months
Hibernate SVN: r15396 - branches/Branch_3_2/HibernateExt/tools/src/testsupport.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2008-10-27 06:56:44 -0400 (Mon, 27 Oct 2008)
New Revision: 15396
Modified:
branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
branches/Branch_3_2/HibernateExt/tools/src/testsupport/coretest-build.xml
Log:
use specific root instead of ../.../...
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2008-10-27 10:38:07 UTC (rev 15395)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2008-10-27 10:56:44 UTC (rev 15396)
@@ -1,23 +1,19 @@
<project name="anttest">
- <property name="hibernate-core.jar" location="../../../../hibernate-3.1/hibernate3.jar" />
- <property name="hibernate-core.home" location="../../../../Hibernate3" />
- <property name="hibernate-core.lib.dir" location="${hibernate-core.home}/lib" />
<property name="build.dir" location="../../build/anttest" />
<property file="../../etc/hibernate.properties" />
+ <property name="jdbc.driver" location="../../lib/jdbc/hsqldb.jar"/>
-
<path id="tasks.classpath">
<pathelement path="../../build/eclipse" />
<pathelement path="../../build/classes" />
- <fileset dir="${hibernate-core.lib.dir}">
+ <fileset dir="${build.dir}/../../lib/testlibs">
<include name="**/*.jar" />
</fileset>
- <pathelement location="${hibernate-core.jar}" />
<pathelement path="../../lib/freemarker.jar" />
- <pathelement path="${hibernate-core.home}\jdbc\hsqldb.jar" />
+ <pathelement path="${jdbc.driver}" />
</path>
@@ -217,15 +213,15 @@
<target name="testantannotationcfg">
<path id="annlib">
- <path location="${hibernate-core.jar}" />
+ <path location="${build.dir}/../../lib/testlibs/hibernate3.jar" />
<path location="${build.dir}/../../lib/testlibs/hibernate-annotations.jar" />
<path location="${build.dir}/../../lib/testlibs/ejb3-persistence.jar" />
<path location="${build.dir}/../classes" />
<path location="${build.dir}/../../etc" />
- <path location="${hibernate-core.home}\jdbc\hsqldb.jar" />
- <fileset dir="${hibernate-core.lib.dir}">
+ <path location="${jdbc.driver}" />
+ <!-- <fileset dir="${hibernate-core.lib.dir}">
<include name="*.jar" />
- </fileset>
+ </fileset> -->
</path>
<taskdef name="hibernatetoolx" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="annlib" />
<hibernatetoolx destdir="${build.dir}/bottomup">
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/coretest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/coretest-build.xml 2008-10-27 10:38:07 UTC (rev 15395)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/coretest-build.xml 2008-10-27 10:56:44 UTC (rev 15396)
@@ -1,19 +1,20 @@
<project name="coreanttest">
- <property name="hibernate-core.jar" location="../../../../hibernate-3.1/hibernate3.jar" />
<property name="hibernate-core.home" location="../../../../hibernate3" />
+ <property name="core.jar" location="${build.dir}/../../lib/testlibs/hibernate3.jar" />
+ <property name="core.libs" location="${build.dir}/../../lib/testlibs" />
<property name="hibernate-core.lib.dir" location="${hibernate-core.home}/lib" />
<property name="build.dir" location="../../build/anttest" />
+ <property name="jdbc.driver" location="../../lib/jdbc/hsqldb.jar"/>
+
<property file="../../etc/hibernate.properties" />
-
-
<path id="tasks.classpath">
- <fileset dir="${hibernate-core.lib.dir}">
+ <!--<fileset dir="${hibernate-core.lib.dir}">
<include name="**/*.jar" />
- </fileset>
+ </fileset>-->
<pathelement location="${hibernate-core.jar}" />
- <pathelement path="${hibernate-core.home}\jdbc\hsqldb.jar" />
+ <pathelement path="${jdbc.driver}" />
</path>
@@ -21,7 +22,7 @@
<target name="test-schemaexportwarning">
<taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="tasks.classpath" />
- <schemaexport drop="true" quiet="false" text="false">
+ <schemaexport drop="true" quiet="false" text="false" output="schemaexport.sql">
<fileset dir="../test" id="id">
<include name="**/*TopDown.hbm.xml" />
</fileset>
@@ -29,13 +30,15 @@
</target>
<target name="test-schemaupdatewarning">
- <taskdef name="schemaupdate" classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask" classpathref="tasks.classpath" />
+ <taskdef name="schemaupdate" classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask" classpathref="tasks.classpath"/>
- <schemaupdate quiet="false" text="false">
+ <schemaupdate quiet="false" text="false" >
<fileset dir="../test" id="id">
<include name="**/*TopDown.hbm.xml" />
</fileset>
</schemaupdate>
+
+
</target>
15 years, 6 months
Hibernate SVN: r15395 - in search/trunk: doc/reference/en/modules and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-27 06:38:07 -0400 (Mon, 27 Oct 2008)
New Revision: 15395
Modified:
search/trunk/common-build.xml
search/trunk/doc/reference/en/modules/query.xml
search/trunk/src/java/org/hibernate/search/annotations/FilterCacheModeType.java
Log:
javadoc updates; replaced references to CacheBitResults with FilterCacheModeType; added link attribute to javadoc ant target in order to link to Lucene online doc
Modified: search/trunk/common-build.xml
===================================================================
--- search/trunk/common-build.xml 2008-10-26 14:39:40 UTC (rev 15394)
+++ search/trunk/common-build.xml 2008-10-27 10:38:07 UTC (rev 15395)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project name="common-build" default="dist"
xmlns:artifact="urn:maven-artifact-ant" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<description>Common properties and targets for the HibernateExt
@@ -14,8 +14,8 @@
<property file="${user.home}/.ant.properties"/>
<property name="src.dir" location="src/java"/>
- <property name="test.dir" location="src/test"/>
- <property name="test.resources.dir" location="src/test-resources"/>
+ <property name="test.dir" location="src/test"/>
+ <property name="test.resources.dir" location="src/test-resources"/>
<property name="filter.dir" location="src/filters"/>
<property name="lib.dir" location="lib"/>
<property name="build.dir" location="build"/>
@@ -199,20 +199,20 @@
<include name="lgpl.txt"/>
</fileset>
</copy>
- </target>
-
- <target name="get.deps.core" depends="init"
- description="retrieve the core dependencies">
- <ivy:resolve conf="default"/>
- <ivy:retrieve pattern="${ivy.dep.dir}/core/[artifact].[ext]"
- conf="default"/>
- </target>
-
- <target name="get.deps.test" depends="init"
- description="retrieve the test dependencies">
- <ivy:resolve conf="test"/>
- <ivy:retrieve pattern="${ivy.dep.dir}/test/[artifact].[ext]" conf="test"/>
+ </target>
+
+ <target name="get.deps.core" depends="init"
+ description="retrieve the core dependencies">
+ <ivy:resolve conf="default"/>
+ <ivy:retrieve pattern="${ivy.dep.dir}/core/[artifact].[ext]"
+ conf="default"/>
</target>
+
+ <target name="get.deps.test" depends="init"
+ description="retrieve the test dependencies">
+ <ivy:resolve conf="test"/>
+ <ivy:retrieve pattern="${ivy.dep.dir}/test/[artifact].[ext]" conf="test"/>
+ </target>
<target name="copytest" description="Copy tests to dist dir" if="copy.test">
<mkdir dir="${dist.test.dir}"/>
@@ -293,6 +293,7 @@
<packageset dir="${src.dir}" defaultexcludes="yes">
<include name="**/*"/>
</packageset>
+ <link href="http://lucene.apache.org/java/2_4_0/api"/>
</javadoc>
</target>
@@ -345,49 +346,49 @@
<mkdir dir="${testclasses.dir}"/>
<copy todir="${testclasses.dir}" filtering="true" overwrite="true">
<fileset dir="${test.resources.dir}">
- <include name="*.properties"/>
+ <include name="*.properties"/>
<include name="*.xml"/>
</fileset>
</copy>
</target>
-
- <target name="instrument" depends="compiletest"
- description="Instrument the persistent classes"> <!-- depends="jar" -->
-
- <taskdef name="instrument"
- classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
- <classpath refid="junit.classpath"/>
- </taskdef>
-
- <instrument verbose="true">
- <fileset dir="${testclasses.dir}/org/hibernate/test">
- <include name="**/*.class"/>
- <exclude name="**/*Test$*.class"/>
- <exclude name="**/*Test.class"/>
- <exclude name="**/*Tests.class"/>
- </fileset>
- </instrument>
+
+ <target name="instrument" depends="compiletest"
+ description="Instrument the persistent classes"> <!-- depends="jar" -->
+
+ <taskdef name="instrument"
+ classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
+ <classpath refid="junit.classpath"/>
+ </taskdef>
+
+ <instrument verbose="true">
+ <fileset dir="${testclasses.dir}/org/hibernate/test">
+ <include name="**/*.class"/>
+ <exclude name="**/*Test$*.class"/>
+ <exclude name="**/*Test.class"/>
+ <exclude name="**/*Tests.class"/>
+ </fileset>
+ </instrument>
</target>
<target name="junitinstrument" depends="compiletest,instrument"
- description="Run the instrument test suite">
- <for list="${targetdb}" param="db">
- <sequential>
- <antcall target="test-resources">
- <param name="db" value="@{db}"/>
- </antcall>
- <mkdir dir="${instrumenttest.out.dir}/@{db}"/>
- <echo>Running against db: @{db}</echo>
- <junit printsummary="yes" haltonfailure="yes" dir="${basedir}"
- maxmemory="256M" fork="yes" forkmode="perBatch">
- <classpath refid="junit.classpath"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${instrumenttest.out.dir}/@{db}" haltonfailure="no">
- <fileset refid="junit.batchtestset"/>
- </batchtest>
- </junit>
- </sequential>
+ description="Run the instrument test suite">
+ <for list="${targetdb}" param="db">
+ <sequential>
+ <antcall target="test-resources">
+ <param name="db" value="@{db}"/>
+ </antcall>
+ <mkdir dir="${instrumenttest.out.dir}/@{db}"/>
+ <echo>Running against db: @{db}</echo>
+ <junit printsummary="yes" haltonfailure="yes" dir="${basedir}"
+ maxmemory="256M" fork="yes" forkmode="perBatch">
+ <classpath refid="junit.classpath"/>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest todir="${instrumenttest.out.dir}/@{db}" haltonfailure="no">
+ <fileset refid="junit.batchtestset"/>
+ </batchtest>
+ </junit>
+ </sequential>
</for>
</target>
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-10-26 14:39:40 UTC (rev 15394)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-10-27 10:38:07 UTC (rev 15395)
@@ -627,7 +627,7 @@
implementation to each of the parameters equals and hashcode
methods.</para>
- <para>As mentioned before the defined filters are per default cache and
+ <para>As mentioned before the defined filters are per default cached and
the cache uses a combination of hard and soft references to allow disposal
of memory when needed. The hard reference cache keeps track of the most
recently used filters and transforms the ones least used to
@@ -646,20 +646,34 @@
<classname>CachingWrapperFilter.</classname> The wrapper will cache the
<classname>BitSet</classname> returned from the
<methodname>bits(IndexReader reader)</methodname> method to avoid
- expensive recomputation.</para>
+ expensive recomputation. The <classname>BitSet</classname> uses one bit
+ per Document. If for example your index contains ten millions documents,
+ the <classname>BitSet</classname> structure will take 1.2 Mb of memory. It
+ is important to mention that the computed <classname>BitSet</classname> is
+ only cachable for the same <classname>IndexReader</classname> instance,
+ because the reader effectively represents the state of the index at the
+ moment it was opened. The document list cannot change within an opened
+ <classname>IndexReader</classname>. A different/new<classname>
+ IndexReader</classname> instance, however, works potentially on a
+ different set of <classname>Document</classname>s (either from a different
+ index or simply because the index has changed), hence the cached
+ <classname>BitSet</classname> has to be recomputed.</para>
- <para>Hibernate Search also takes care of this aspect of caching. If the
- <literal>cache</literal> flag of <classname>@FullTextFilterDef
- </classname>is set to <literal>true</literal>, it will automatically wrap
- the specified filter around a Hibernate specific implementation of
- CachingWrapperFilter
+ <para>Hibernate Search also helps with this aspect of caching. Per default
+ the <literal>cache</literal> flag of <classname>@FullTextFilterDef
+ </classname>is set to
+ <literal>FilterCacheModeType.INSTANCE_AND_BITSETRESULTS</literal> which
+ will automatically cache the filter instance as well as wrap the specified
+ filter around a Hibernate specific implementation of
+ <classname>CachingWrapperFilter</classname>
(<classname>org.hibernate.search.filter.CachingWrapperFilter</classname>).
- In contrast to Lucene's version of this class SoftReferences are used
- together with a hard reference count (see dicussion about filter cache).
- The hard reference count can be adjusted using
+ In contrast to Lucene's version of this class
+ <classname>SoftReference</classname>s are used together with a hard
+ reference count (see dicussion about filter cache). The hard reference
+ count can be adjusted using
<literal>hibernate.search.filter.cache_bit_results.size</literal>
- (defaults to 5). The wrapping behaviour can be controlled by
- <literal>@FullTextFilterDef.cacheBitResult</literal>. There are two
+ (defaults to 5). The wrapping behaviour can be controlled using the
+ <literal>@FullTextFilterDef.cache</literal> parameter. There are three
differerent values for this parameter:</para>
<para><informaltable align="left" width="">
@@ -676,21 +690,34 @@
<tbody>
<row>
- <entry align="left">CacheBitResults.AUTOMATIC</entry>
+ <entry align="left">FilterCacheModeType.NONE</entry>
- <entry>The use of <classname>CachingWrapperFilter</classname>
- depends on the <literal>cache</literal> paramter of the filter
- defintion. If <literal>cache</literal> is set to
- <literal>true</literal> a wrapper will be used, otherwise not.
- <literal>CacheBitResults.AUTOMATIC</literal> is the default
- value.</entry>
+ <entry>No filter instance and no result is cached by Hibernate
+ Search. For every filter call, a new filter instance is created.
+ This setting might be useful for rapidly changing data sets or
+ heavily memory constrained environments. </entry>
</row>
<row>
- <entry align="left">CacheBitResults.NO</entry>
+ <entry align="left">FilterCacheModeType.INSTANCE_ONLY</entry>
- <entry>No wrapper will be used.</entry>
+ <entry>The filter instance is cached and reused across
+ concurrent <methodname>Filter.bits()</methodname> calls.
+ <classname>BitSet</classname> results are not cached. This
+ setting is useful when a filter uses its own specific caching
+ mechanism or the filter results change dynamically due to
+ application specific events making <classname>BitSet</classname>
+ caching in both cases unnecessary. </entry>
</row>
+
+ <row>
+ <entry
+ align="left">FilterCacheModeType.INSTANCE_AND_BITSETRESULTS</entry>
+
+ <entry>Both the filter instance and the
+ <classname>BitSet</classname> results are cached. This is the
+ default value.</entry>
+ </row>
</tbody>
</tgroup>
</informaltable>Last but not least - why should filters be cached? There
Modified: search/trunk/src/java/org/hibernate/search/annotations/FilterCacheModeType.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/FilterCacheModeType.java 2008-10-26 14:39:40 UTC (rev 15394)
+++ search/trunk/src/java/org/hibernate/search/annotations/FilterCacheModeType.java 2008-10-27 10:38:07 UTC (rev 15395)
@@ -1,29 +1,35 @@
package org.hibernate.search.annotations;
/**
- * Cache mode strategy for Full Text filters
+ * Cache mode strategy for <code>FullTextFilterDef</code>s.
*
+ * @see FullTextFilterDef
* @author Emmanuel Bernard
*/
public enum FilterCacheModeType {
/**
- * No filter instance and no result is cached by Hibernate Search
- * For every filter call, a new filter instance is created
+ * No filter instance and no result is cached by Hibernate Search.
+ * For every filter call, a new filter instance is created.
*/
NONE,
/**
* The filter instance is cached by Hibernate Search and reused across
- * concurrent filter.bits() calls
- * Results are not cache by Hibernate Search
+ * concurrent <code>Filter.bits()</code> calls.
+ * Results are not cached by Hibernate Search.
+ *
+ * @see org.apache.lucene.search.Filter#bits(org.apache.lucene.index.IndexReader)
+
*/
INSTANCE_ONLY,
/**
- * Both the filter instance and the BitSet results are cached.
+ * Both the filter instance and the <code>BitSet</code> results are cached.
* The filter instance is cached by Hibernate Search and reused across
- * concurrent filter.bits() calls
- * BitSet Results are cached per IndexReader
+ * concurrent <code>Filter.bits()</code> calls.
+ * <code>BitSet</code> results are cached per <code>IndexReader</code>.
+ *
+ * @see org.apache.lucene.search.Filter#bits(org.apache.lucene.index.IndexReader)
*/
INSTANCE_AND_BITSETRESULTS
15 years, 6 months
Hibernate SVN: r15394 - search/trunk/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-26 10:39:40 -0400 (Sun, 26 Oct 2008)
New Revision: 15394
Modified:
search/trunk/doc/reference/en/modules/query.xml
Log:
fixed some wording in filter section
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-10-26 13:07:36 UTC (rev 15393)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-10-26 14:39:40 UTC (rev 15394)
@@ -499,22 +499,23 @@
fullTextQuery.list(); //returns only best drivers where andre has credentials</programlisting>
<para>In this example we enabled two filters on top of the query. You can
- enable (or disable) as many filters as you want.</para>
+ enable (or disable) as many filters as you like.</para>
<para>Declaring filters is done through the
<classname>@FullTextFilterDef</classname> annotation. This annotation can
be on any <literal>@Indexed</literal> entity regardless of the query the
- filter is later applied to. This means filter definitions are global and
- their names must be unique. A <classname>SearchException</classname> is
- thrown in case two different <classname>@FullTextFilterDef</classname>
- annotations with the same name are defined. Each named filter has to point
- to an actual filter implementation.</para>
+ filter is later applied to. This implies that filter definitions are
+ global and their names must be unique. A
+ <classname>SearchException</classname> is thrown in case two different
+ <classname>@FullTextFilterDef</classname> annotations with the same name
+ are defined. Each named filter has to specify its actual filter
+ implementation.</para>
<programlisting>@Entity
@Indexed
@FullTextFilterDefs( {
- <emphasis role="bold">@FullTextFilterDef(name = "bestDriver", impl = BestDriversFilter.class, cache=false)</emphasis>, //actual Filter implementation
- <emphasis role="bold">@FullTextFilterDef(name = "security", impl = SecurityFilterFactory.class)</emphasis> //Filter factory with parameters
+ <emphasis role="bold">@FullTextFilterDef(name = "bestDriver", impl = BestDriversFilter.class, cache=false)</emphasis>,
+ <emphasis role="bold">@FullTextFilterDef(name = "security", impl = SecurityFilterFactory.class)</emphasis>
})
public class Driver { ... }</programlisting>
@@ -532,8 +533,8 @@
}</programlisting>
<para><classname>BestDriversFilter</classname> is an example of a simple
- Lucene filter that will filter all results returning only drivers whose
- score is 5. In this example the specified filter implements the
+ Lucene filter which reduces the result set to drivers whose score is 5. In
+ this example the specified filter implements the
<literal>org.apache.lucene.search.Filter</literal> directly and contains a
no-arg constructor. The <literal>cache</literal> flag, defaulted to
<literal>true</literal>, tells Hibernate Search to search the filter in
@@ -545,7 +546,7 @@
<programlisting>@Entity
@Indexed
-@FullTextFilterDef(name = "bestDriver", impl = BestDriversFilterFactory.class) //Filter factory
+@FullTextFilterDef(name = "bestDriver", impl = BestDriversFilterFactory.class)
public class Driver { ... }
public class BestDriversFilterFactory {
@@ -600,12 +601,12 @@
<para>Note the method annotated <classname>@Key</classname> returning a
<classname>FilterKey</classname> object. The returned object has a special
- contract: the key object must implement equals / hashcode so that 2 keys
- are equal if and only if the given <classname>Filter</classname> types are
- the same and the set of parameters are the same. In other words, 2 filter
- keys are equal if and only if the filters from which the keys are
- generated can be interchanged. The key object is used as a key in the
- cache mechanism.</para>
+ contract: the key object must implement <methodname>equals()</methodname>
+ / <methodname>hashcode()</methodname> so that 2 keys are equal if and only
+ if the given <classname>Filter</classname> types are the same and the set
+ of parameters are the same. In other words, 2 filter keys are equal if and
+ only if the filters from which the keys are generated can be interchanged.
+ The key object is used as a key in the cache mechanism.</para>
<para><classname>@Key</classname> methods are needed only if:</para>
@@ -621,29 +622,31 @@
</itemizedlist>
<para>In most cases, using the <literal>StandardFilterKey</literal>
- implementation will be good enough. It delegates the equals / hashcode
+ implementation will be good enough. It delegates the
+ <methodname>equals()</methodname> / <methodname>hashcode()</methodname>
implementation to each of the parameters equals and hashcode
methods.</para>
- <para>The filter cache is enabled by default and uses a combination of
- hard and soft references to allow disposal of memory when needed. The hard
- reference cache keeps track of the most recently used filters and
- transforms the ones least used to <classname>SoftReferences</classname>
- when needed. Once the limit of the hard reference cache is reached
- addtional filters are cached as <classname>SoftReferences</classname>. To
- adjust the size of the hard reference cache, use
+ <para>As mentioned before the defined filters are per default cache and
+ the cache uses a combination of hard and soft references to allow disposal
+ of memory when needed. The hard reference cache keeps track of the most
+ recently used filters and transforms the ones least used to
+ <classname>SoftReferences</classname> when needed. Once the limit of the
+ hard reference cache is reached addtional filters are cached as
+ <classname>SoftReferences</classname>. To adjust the size of the hard
+ reference cache, use
<literal>hibernate.search.filter.cache_strategy.size</literal> (defaults
to 128). For advance use of filter caching, you can implement your own
<classname>FilterCachingStrategy</classname>. The classname is defined by
<literal>hibernate.search.filter.cache_strategy</literal>.</para>
- <para>The described filter cache mechanism should not be confused with
- caching the actual filter results. In Lucene it is common practice to wrap
- filters using the <classname>IndexReader</classname> around a
+ <para>This filter caching mechanism should not be confused with caching
+ the actual filter results. In Lucene it is common practice to wrap filters
+ using the <classname>IndexReader</classname> around a
<classname>CachingWrapperFilter.</classname> The wrapper will cache the
<classname>BitSet</classname> returned from the
- <methodname>bits(IndexReader reader)</methodname>method to avoid expensive
- recomputation.</para>
+ <methodname>bits(IndexReader reader)</methodname> method to avoid
+ expensive recomputation.</para>
<para>Hibernate Search also takes care of this aspect of caching. If the
<literal>cache</literal> flag of <classname>@FullTextFilterDef
@@ -737,4 +740,4 @@
run Lucene specific queries. Check <xref linkend="search-lucene-native" />
for more informations.</para>
</section>
-</chapter>
\ No newline at end of file
+</chapter>
15 years, 6 months
Hibernate SVN: r15393 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-26 09:07:36 -0400 (Sun, 26 Oct 2008)
New Revision: 15393
Modified:
search/trunk/build.xml
Log:
HSEARCH-287 - exluded master.xml in build
Modified: search/trunk/build.xml
===================================================================
--- search/trunk/build.xml 2008-10-25 22:00:53 UTC (rev 15392)
+++ search/trunk/build.xml 2008-10-26 13:07:36 UTC (rev 15393)
@@ -259,6 +259,7 @@
<copy todir="${dist.dir}/doc/reference" failonerror="false">
<fileset dir="${basedir}/doc/reference/build">
<include name="**/*.*"/>
+ <exclude name="en/master.xml"/>
</fileset>
</copy>
15 years, 6 months
Hibernate SVN: r15392 - search/trunk/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-10-25 18:00:53 -0400 (Sat, 25 Oct 2008)
New Revision: 15392
Modified:
search/trunk/doc/reference/en/modules/mapping.xml
search/trunk/doc/reference/en/modules/query.xml
Log:
Do add docu for scoped analyzers
Modified: search/trunk/doc/reference/en/modules/mapping.xml
===================================================================
--- search/trunk/doc/reference/en/modules/mapping.xml 2008-10-25 16:13:51 UTC (rev 15391)
+++ search/trunk/doc/reference/en/modules/mapping.xml 2008-10-25 22:00:53 UTC (rev 15392)
@@ -809,6 +809,65 @@
<classname>org.apache.solr.analysis.TokenFilterFactory</classname> in
your IDE to see the implementations available.</para>
</section>
+
+ <section id="analyzer-retrievinganalyzer">
+ <title>Retrieving an analyzer</title>
+
+ <para>During indexing time, Hibernate Search is using analyzers under
+ the hood for you. In some situations, retrieving analyzers can be
+ handy. If your domain model makes use of multiple analyzers (maybe to
+ benefit from stemming, use phonetic approximation and so on), you need
+ to make sure to use the same analyzers when you build your query.
+ </para>
+
+ <note>
+ <para>This rule can be broken but you need a good reason for it. If
+ you are unsure, use the same analyzers.</para>
+ </note>
+
+ <para>You can retrieve the scoped analyzer for a given entity used at
+ indexing time by Hibernate Search. A scoped analyzer is an analyzer
+ which applies the right analyzers depending on the field indexed:
+ multiple analyzers can be defined on a given entity each one working
+ on an individual field, a scoped analyzer unify all these analyzers
+ into a context-aware analyzer. While the theory seems a bit complex,
+ using the right analyzer in a query is very easy. </para>
+
+ <example>
+ <title>Using the scoped analyzer when building a full-text
+ query</title>
+
+ <programlisting>org.apache.lucene.queryParser.QueryParser parser = new QueryParser(
+ "title",
+ fullTextSession.getSearchFactory().getAnalyzer( Song.class )
+);
+
+org.apache.lucene.search.Query luceneQuery = parser.parse( "title:sky Or title_stemmed:diamond" );
+
+org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery, Song.class );
+
+List result = fullTextQuery.list(); //return a list of managed objects </programlisting>
+ </example>
+
+ <para>In the example above, the song title is indexed in two fields:
+ the standard analyzer is used in the field <literal>title</literal>
+ and a stemming analyzer is used in the field
+ <literal>title_stemmed</literal>. By using the analyzer provided by
+ the search factory, the query uses the appropriate analyzer depending
+ on the field targeted.</para>
+
+ <note>
+ <para>This is true if you use the query parser which takes the
+ analyzer into consideration. If you do not use the Lucene query
+ parser, make sure to use the scoped analyzer and tokenize the query
+ accordingly. TODO: show an example</para>
+ </note>
+
+ <para>If your query targets more that one query and you wish to use
+ your standard analyzer, make sure to describe it using an analyzer
+ definition. You can retrieve analyzers by their definition name using
+ <code>searchFactory.getAnalyzer(String)</code>.</para>
+ </section>
</section>
</section>
@@ -1184,13 +1243,17 @@
<section id="provided-id">
<title>Providing your own id</title>
+ <warning>
+ <para>This part of the documentation is a work in progress.</para>
+ </warning>
+
<para>You can provide your own id for Hibernate Search if you are
extending the internals. You will have to generate a unique value so it
can be given to Lucene to be indexed. This will have to be given to
Hibernate Search when you create an org.hibernate.search.Work object - the
document id is required in the constructor.</para>
- <section id="@ProvidedId">
+ <section id="ProvidedId">
<title>The @ProvidedId annotation</title>
<para>Unlike conventional Hibernate Search API and @DocumentId, this
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-10-25 16:13:51 UTC (rev 15391)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-10-25 22:00:53 UTC (rev 15392)
@@ -22,8 +22,8 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="search-query" xreflabel="Querying">
<!-- $Id$ -->
@@ -95,15 +95,22 @@
<title>Building a Lucene query</title>
<para>This subject is generally speaking out of the scope of this
- documentation. Please refer to the Lucene documentation or Lucene In
- Action.</para>
+ documentation. Please refer to the Lucene documentation Lucene In Action
+ or Hibernate Search in Action from Manning.</para>
- <para>It is quite useful to use the same analyzer when indexing a field
- and when querying that field. Hibernate Search let's you access analyzer
- instances that have been defined through an analyzer definition (see
- <xref linkend="analyzer" /> for more information).</para>
+ <para>It is essential to use the same analyzer when indexing a field and
+ when querying that field. Hibernate Search gives you access to the
+ analyzers used during indexing time (see <xref
+ linkend="analyzer-retrievinganalyzer" /> for more information).</para>
- <programlisting>analyzer analyzer = fullTextSession.getSearchFactory().getAnalyzer("phonetic-analyzer");</programlisting>
+ <programlisting>//retrieve an analyzer by name
+Analyzer analyzer = fullTextSession.getSearchFactory().getAnalyzer("phonetic-analyzer");
+
+//or the scoped analyzer for a given entity
+Analyzer analyzer = fullTextSession.getSearchFactory().getAnalyzer(Song.class);</programlisting>
+
+ <para>Using the same analyzer at indexing and querying time is
+ important. See <xref linkend="analyzer" /> for more information.</para>
</section>
<section>
@@ -681,7 +688,6 @@
<entry>No wrapper will be used.</entry>
</row>
-
</tbody>
</tgroup>
</informaltable>Last but not least - why should filters be cached? There
15 years, 6 months
Hibernate SVN: r15390 - search/trunk/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-10-24 18:41:43 -0400 (Fri, 24 Oct 2008)
New Revision: 15390
Modified:
search/trunk/doc/reference/en/modules/batchindex.xml
search/trunk/doc/reference/en/modules/configuration.xml
Log:
Update various docuimentation bits
Modified: search/trunk/doc/reference/en/modules/batchindex.xml
===================================================================
--- search/trunk/doc/reference/en/modules/batchindex.xml 2008-10-24 17:42:28 UTC (rev 15389)
+++ search/trunk/doc/reference/en/modules/batchindex.xml 2008-10-24 22:41:43 UTC (rev 15390)
@@ -130,7 +130,8 @@
index but will not touch the database.</para>
<para>If you need to remove all entities of a given type, you can use the
- <methodname>purgeAll</methodname> method.</para>
+ <methodname>purgeAll</methodname> method. This operation remove all entities of the type passed
+ as a parameter as well as all its subtypes.</para>
<programlisting>FullTextSession fullTextSession = Search.getFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
Modified: search/trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- search/trunk/doc/reference/en/modules/configuration.xml 2008-10-24 17:42:28 UTC (rev 15389)
+++ search/trunk/doc/reference/en/modules/configuration.xml 2008-10-24 22:41:43 UTC (rev 15390)
@@ -184,7 +184,7 @@
</section>
<section id="search-configuration-directory-sharding" revision="1">
- <title>Index sharding</title>
+ <title>Sharding indexes</title>
<para>In some extreme cases involving huge indexes (in size), it is
necessary to split (shard) the indexing data of a given entity type into
@@ -264,6 +264,50 @@
</section>
<section>
+ <title>Sharing indexes (two entities into the same directory)</title>
+
+ <para>It is possible to store more than one entity index information into
+ a single Lucene index.</para>
+
+ <note>
+ <para>This is only presented here so that you know the option is
+ available. There is really not much benefit in sharing indexes.</para>
+ </note>
+
+ <para>There are actually two ways to accomplish merging an index:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Configuring the underlying directory providers to point to the
+ same physical index directory. In practice, you set the property
+ <literal>hibernate.search.[fully qualified entity
+ name].indexName=(relative directory from indexBase)</literal> to the
+ same value.</para>
+
+ <para>For example, let’s say that we want the Furniture entity to
+ actually be stored in the same directory as the Animal entity. We
+ would have the configuration setting set to “Animal”. Both entities
+ will then be stored in the Animal directory</para>
+
+ <para><programlisting><code>hibernate.search.org.hibernate.search.test.shards.Furniture.indexName = Aninal
+hibernate.search.org.hibernate.search.test.shards.Animal.indexName = Aninal</code></programlisting></para>
+ </listitem>
+
+ <listitem>
+ <para>Setting the <code>@Indexed</code> annotation’s
+ <methodname>index</methodname> attribute of the entities you want to
+ merge to the same value.</para>
+
+ <para>If we wanted all Furniture instances to be indexed in the Animal
+ index along with all instances of Animal we would specify
+ <code>@Indexed(index=”Animal”)</code> on both
+ <classname>Animal</classname> and <classname>Furniture</classname>
+ classes.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
<title>Worker configuration</title>
<para>It is possible to refine how Hibernate Search interacts with Lucene
@@ -613,45 +657,26 @@
hibernate.search.Animals.2.indexwriter.transaction.merge_factor 20
hibernate.search.default.indexwriter.batch.max_merge_docs 100</programlisting>
This configuration will result in these settings applied to the second
- shard of Animals index: <itemizedlist>
- <listitem>
-
-
- <literal>transaction.max_merge_docs</literal>
-
- = 10
+ shard of Animals index:</para> <itemizedlist>
+ <listitem><para><literal>transaction.max_merge_docs</literal> = 10</para>
</listitem>
- <listitem>
-
-
- <literal>batch.max_merge_docs</literal>
-
- = 100
+ <listitem><para><literal>batch.max_merge_docs</literal> = 100</para>
</listitem>
- <listitem>
-
+ <listitem><para><literal>transaction.merge_factor</literal> = 20</para></listitem>
- <literal>transaction.merge_factor</literal>
-
- = 20
+ <listitem><para><literal>batch.merge_factor</literal> = 20</para>
</listitem>
+ </itemizedlist>
- <listitem>
-
-
- <literal>batch.merge_factor</literal>
-
- = 20
- </listitem>
- </itemizedlist> All other values will use the defaults defined in
+ <para>All other values will use the defaults defined in
Lucene.</para>
<para>The default for all values is to leave them at Lucene's own default,
so the listed values in the following table actually depend on the version
of Lucene you are using; values shown are relative to version
- <literal>2.3</literal>. For more information about Lucene indexing
+ <literal>2.4</literal>. For more information about Lucene indexing
performances, please refer to the Lucene documentation.</para>
<table>
@@ -785,4 +810,4 @@
</tgroup>
</table>
</section>
-</chapter>
+</chapter>
\ No newline at end of file
15 years, 6 months
Hibernate SVN: r15389 - in search/trunk: src/java/org/hibernate/search/annotations and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-10-24 13:42:28 -0400 (Fri, 24 Oct 2008)
New Revision: 15389
Added:
search/trunk/src/test/org/hibernate/search/test/query/boost/
search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java
search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java
search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java
search/trunk/src/test/org/hibernate/search/test/query/boost/FieldBoostTest.java
search/trunk/src/test/org/hibernate/search/test/query/boost/Library.java
Modified:
search/trunk/doc/reference/en/modules/mapping.xml
search/trunk/src/java/org/hibernate/search/annotations/Field.java
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
HSEARCH-170 @Boost is now supposed on @Field in a cummulative way
Modified: search/trunk/doc/reference/en/modules/mapping.xml
===================================================================
--- search/trunk/doc/reference/en/modules/mapping.xml 2008-10-24 15:48:35 UTC (rev 15388)
+++ search/trunk/doc/reference/en/modules/mapping.xml 2008-10-24 17:42:28 UTC (rev 15389)
@@ -492,13 +492,13 @@
<title>Boost factor</title>
<para>Lucene has the notion of <emphasis>boost factor</emphasis>. It's a
- way to give more weigth to a field or to an indexed element over an
- other during the indexation process. You can use
- <literal>@Boost</literal> at the field or the class level.</para>
+ way to give more weigth to a field or to an indexed element over others
+ during the indexation process. You can use <literal>@Boost</literal> at
+ the @Field, method or class level.</para>
<programlisting>@Entity
@Indexed(index="indexes/essays")
-<emphasis role="bold">@Boost(2)</emphasis>
+<emphasis role="bold">@Boost(1.7f)</emphasis>
public class Essay {
...
@@ -506,21 +506,34 @@
@DocumentId
public Long getId() { return id; }
- @Field(name="Abstract", index=Index.TOKENIZED, store=Store.YES)
- <emphasis role="bold">@Boost(2.5f)</emphasis>
+ @Field(name="Abstract", index=Index.TOKENIZED, store=Store.YES, boost=<emphasis
+ role="bold">@Boost(2f)</emphasis>)
+ <emphasis role="bold">@Boost(1.5f)</emphasis>
public String getSummary() { return summary; }
@Lob
- @Field(index=Index.TOKENIZED)
+ @Field(index=Index.TOKENIZED, boost=<emphasis role="bold">@Boost(1.2f)</emphasis>)
public String getText() { return text; }
+
+ @Field
+ public String getISBN() { return isbn; }
+
} </programlisting>
<para>In our example, Essay's probability to reach the top of the search
- list will be multiplied by 2 and the summary field will be 2.5 more
- important than the test field. Note that this explaination is actually
- wrong, but it is simple and close enought to the reality. Please check
- the Lucene documentation or the excellent <citetitle>Lucene In Action
- </citetitle> from Otis Gospodnetic and Erik Hatcher.</para>
+ list will be multiplied by 1.7. The <methodname>summary</methodname>
+ field will be 2.5 (2 * 1.5) more important than the
+ <methodname>isbn</methodname> field. The <methodname>text</methodname>
+ field will be 1.2 times more important than the
+ <methodname>isbn</methodname> field. Note that this explanation in
+ strictest terms is actually wrong, but it is simple and close enough to
+ reality for all practical purposes. Please check the Lucene
+ documentation or the excellent <citetitle>Lucene In Action </citetitle>
+ from Otis Gospodnetic and Erik Hatcher.</para>
+
+ <para><methodname>@Field.boost</methodname>,
+ <classname>@Boost</classname> on a property and
+ <classname>@Boost</classname> on a class are all cumulative.</para>
</section>
<section id="analyzer">
@@ -1206,4 +1219,4 @@
</programlisting>
</section>
</section>
-</chapter>
+</chapter>
\ No newline at end of file
Modified: search/trunk/src/java/org/hibernate/search/annotations/Field.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/Field.java 2008-10-24 15:48:35 UTC (rev 15388)
+++ search/trunk/src/java/org/hibernate/search/annotations/Field.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -49,9 +49,14 @@
*/
Analyzer analyzer() default @Analyzer;
+
/**
* Field bridge used. Default is autowired.
*/
+ Boost boost() default @Boost( value = 1.0F );
+
+ /**
+ * Field bridge used. Default is autowired.
+ */
FieldBridge bridge() default @FieldBridge;
-
}
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-10-24 15:48:35 UTC (rev 15388)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -80,7 +80,7 @@
public static final String CLASS_FIELDNAME = "_hibernate_class";
private TwoWayFieldBridge idBridge;
private Set<Class<?>> mappedSubclasses = new HashSet<Class<?>>();
- private ReflectionManager reflectionManager;
+ private ReflectionManager reflectionManager; //available only during initializationa nd post-initialization
private int level = 0;
private int maxLevel = Integer.MAX_VALUE;
private final ScopedAnalyzer analyzer = new ScopedAnalyzer();
@@ -105,7 +105,7 @@
this.beanClass = clazz;
this.directoryProviders = directoryProviders;
this.shardingStrategy = shardingStrategy;
- //FIXME get rid of it when boost is stored?
+ //set to null after post-initialization
this.reflectionManager = reflectionManager;
this.similarity = context.getDefaultSimilarity();
@@ -126,7 +126,7 @@
ProvidedId provided = findProvidedId( clazz, reflectionManager );
if ( provided == null ) throw new SearchException( "No document id in: " + clazz.getName() );
- idBridge = BridgeFactory.extractTwoWayType(provided.bridge());
+ idBridge = BridgeFactory.extractTwoWayType( provided.bridge() );
idKeywordName = provided.name();
}
//if composite id, use of (a, b) in ((1,2)TwoWayString2FieldBridgeAdaptor, (3,4)) fails on most database
@@ -143,12 +143,12 @@
this.directoryProviders = null;
this.shardingStrategy = null;
- //FIXME get rid of it when boost is stored?
+
this.reflectionManager = reflectionManager;
this.similarity = context.getDefaultSimilarity();
init( clazz, context, reflectionManager );
- if (rootPropertiesMetadata.containedInGetters.size() == 0) {
+ if ( rootPropertiesMetadata.containedInGetters.size() == 0 ) {
this.entityState = EntityState.NON_INDEXABLE;
}
}
@@ -156,7 +156,7 @@
private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
ProvidedId id = null;
XClass currentClass = clazz;
- while ( id == null && ( ! reflectionManager.equals( currentClass, Object.class ) ) ) {
+ while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
id = currentClass.getAnnotation( ProvidedId.class );
currentClass = clazz.getSuperclass();
}
@@ -303,7 +303,7 @@
throw new SearchException(
"Bridge for document id does not implement TwoWayFieldBridge: " + member.getName() );
}
- idBoost = getBoost( member );
+ idBoost = getBoost( member, null );
setAccessible( member );
idGetter = member;
}
@@ -317,6 +317,7 @@
propertiesMetadata.fieldIndex.add( getIndex( Index.UN_TOKENIZED ) );
propertiesMetadata.fieldTermVectors.add( getTermVector( TermVector.NO ) );
propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( null, member, reflectionManager ) );
+ propertiesMetadata.fieldBoosts.add( getBoost( member, null ) );
// property > entity analyzer (no field analyzer)
Analyzer analyzer = getAnalyzer( member, context );
if ( analyzer == null ) analyzer = propertiesMetadata.analyzer;
@@ -351,7 +352,7 @@
}
maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
level++;
-
+
XClass elementClass;
if ( void.class == embeddedAnn.targetElement() ) {
elementClass = member.getElementClass();
@@ -375,7 +376,7 @@
propertiesMetadata.embeddedGetters.add( member );
PropertiesMetadata metadata = new PropertiesMetadata();
propertiesMetadata.embeddedPropertiesMetadata.add( metadata );
- metadata.boost = getBoost( member );
+ metadata.boost = getBoost( member, null );
//property > entity analyzer
Analyzer analyzer = getAnalyzer( member, context );
metadata.analyzer = analyzer != null ? analyzer : propertiesMetadata.analyzer;
@@ -441,6 +442,7 @@
propertiesMetadata.fieldNames.add( fieldName );
propertiesMetadata.fieldStore.add( getStore( fieldAnn.store() ) );
propertiesMetadata.fieldIndex.add( getIndex( fieldAnn.index() ) );
+ propertiesMetadata.fieldBoosts.add( getBoost(member, fieldAnn) );
propertiesMetadata.fieldTermVectors.add( getTermVector( fieldAnn.termVector() ) );
propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( fieldAnn, member, reflectionManager ) );
@@ -452,6 +454,14 @@
}
}
+ private Float getBoost(XProperty member, org.hibernate.search.annotations.Field fieldAnn) {
+ float computedBoost = 1.0f;
+ Boost boostAnn = member.getAnnotation( Boost.class );
+ if (boostAnn != null) computedBoost = boostAnn.value();
+ if (fieldAnn != null) computedBoost *= fieldAnn.boost().value();
+ return computedBoost;
+ }
+
private String buildEmbeddedPrefix(String prefix, IndexedEmbedded embeddedAnn, XProperty member) {
String localPrefix = prefix;
if ( ".".equals( embeddedAnn.prefix() ) ) {
@@ -509,7 +519,7 @@
}
}
- private Float getBoost(XAnnotatedElement element) {
+ private Float getBoost(XClass element) {
if ( element == null ) return null;
Boost boost = element.getAnnotation( Boost.class );
return boost != null ?
@@ -541,14 +551,14 @@
Serializable currentId = luceneWork.getId();
//currentId != null => either ADD or Delete work
if ( currentId != null && currentId.equals( id ) ) { //find a way to use Type.equals(x,y)
- if (workType == WorkType.DELETE) { //TODO add PURGE?
+ if ( workType == WorkType.DELETE ) { //TODO add PURGE?
//DELETE should have precedence over any update before (HSEARCH-257)
//if an Add work is here, remove it
//if an other delete is here remember but still search for Add
- if (luceneWork instanceof AddLuceneWork) {
+ if ( luceneWork instanceof AddLuceneWork ) {
toDelete.add( luceneWork );
}
- else if (luceneWork instanceof DeleteLuceneWork) {
+ else if ( luceneWork instanceof DeleteLuceneWork ) {
duplicateDelete = true;
}
}
@@ -560,10 +570,10 @@
//TODO do something to avoid multiple PURGE ALL and OPTIMIZE
}
}
- for ( LuceneWork luceneWork : toDelete ) {
+ for (LuceneWork luceneWork : toDelete) {
toDelete.remove( luceneWork );
}
- if (duplicateDelete) return;
+ if ( duplicateDelete ) return;
String idInString = idBridge.objectToString( id );
if ( workType == WorkType.ADD ) {
@@ -660,13 +670,13 @@
public Document getDocument(T instance, Serializable id) {
Document doc = new Document();
final Class<?> entityType = Hibernate.getClass( instance );
- XClass instanceClass = reflectionManager.toXClass( entityType );
+ //XClass instanceClass = reflectionManager.toXClass( entityType );
if ( rootPropertiesMetadata.boost != null ) {
doc.setBoost( rootPropertiesMetadata.boost );
}
{
Field classField =
- new Field( CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO );
+ new Field( CLASS_FIELDNAME, entityType.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO );
doc.add( classField );
LuceneOptions luceneOptions = new LuceneOptionsImpl( Field.Store.YES,
Field.Index.UN_TOKENIZED, Field.TermVector.NO, idBoost );
@@ -690,7 +700,7 @@
Object value = getMemberValue( unproxiedInstance, member );
propertiesMetadata.fieldBridges.get( i ).set(
propertiesMetadata.fieldNames.get( i ), value, doc,
- propertiesMetadata.getFieldLuceneOptions( i, getBoost( member ) ) );
+ propertiesMetadata.getFieldLuceneOptions( i ) );
}
for (int i = 0; i < propertiesMetadata.embeddedGetters.size(); i++) {
XMember member = propertiesMetadata.embeddedGetters.get( i );
@@ -744,15 +754,15 @@
}
public DirectoryProvider[] getDirectoryProviders() {
- if( entityState != EntityState.INDEXED ) {
- throw new AssertionFailure("Contained in only entity: getDirectoryProvider should not have been called.");
+ if ( entityState != EntityState.INDEXED ) {
+ throw new AssertionFailure( "Contained in only entity: getDirectoryProvider should not have been called." );
}
return directoryProviders;
}
public IndexShardingStrategy getDirectoryProviderSelectionStrategy() {
- if( entityState != EntityState.INDEXED ) {
- throw new AssertionFailure("Contained in only entity: getDirectoryProviderSelectionStrategy should not have been called.");
+ if ( entityState != EntityState.INDEXED ) {
+ throw new AssertionFailure( "Contained in only entity: getDirectoryProviderSelectionStrategy should not have been called." );
}
return shardingStrategy;
}
@@ -857,7 +867,8 @@
}
public void postInitialize(Set<Class<?>> indexedClasses) {
- if (entityState == EntityState.NON_INDEXABLE) throw new AssertionFailure("A non indexed entity is post processed");
+ if ( entityState == EntityState.NON_INDEXABLE )
+ throw new AssertionFailure( "A non indexed entity is post processed" );
//this method does not requires synchronization
Class plainClass = reflectionManager.toClass( beanClass );
Set<Class<?>> tempMappedSubclasses = new HashSet<Class<?>>();
@@ -875,6 +886,7 @@
}
superClass = superClass.getSuperclass();
}
+ this.reflectionManager = null;
}
public EntityState getEntityState() {
@@ -904,6 +916,7 @@
public final List<FieldBridge> fieldBridges = new ArrayList<FieldBridge>();
public final List<Field.Store> fieldStore = new ArrayList<Field.Store>();
public final List<Field.Index> fieldIndex = new ArrayList<Field.Index>();
+ public final List<Float> fieldBoosts = new ArrayList<Float>();
public final List<Field.TermVector> fieldTermVectors = new ArrayList<Field.TermVector>();
public final List<XMember> embeddedGetters = new ArrayList<XMember>();
public final List<PropertiesMetadata> embeddedPropertiesMetadata = new ArrayList<PropertiesMetadata>();
@@ -929,9 +942,10 @@
return options;
}
- private LuceneOptions getFieldLuceneOptions(int i, Float boost) {
- LuceneOptions options = new LuceneOptionsImpl( fieldStore.get( i ),
- fieldIndex.get( i ), fieldTermVectors.get( i ), boost );
+ private LuceneOptions getFieldLuceneOptions(int i) {
+ LuceneOptions options;
+ options = new LuceneOptionsImpl( fieldStore.get( i ),
+ fieldIndex.get( i ), fieldTermVectors.get( i ), fieldBoosts.get( i ) );
return options;
}
}
Added: search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedDescriptionLibrary.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -0,0 +1,67 @@
+package org.hibernate.search.test.query.boost;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author John Griffin
+ */
+@Entity
+@Indexed
+@Analyzer(impl = StandardAnalyzer.class)
+public class BoostedDescriptionLibrary {
+ private int id;
+ private String title;
+ private String author;
+ private String description;
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Boost(2.0F)
+ @Field(store = Store.YES, index = Index.TOKENIZED, boost = @Boost(2.0F))
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
\ No newline at end of file
Added: search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedFieldDescriptionLibrary.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -0,0 +1,66 @@
+package org.hibernate.search.test.query.boost;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author John Griffin
+ */
+@Entity
+@Indexed
+@Analyzer(impl = StandardAnalyzer.class)
+public class BoostedFieldDescriptionLibrary {
+ private int id;
+ private String title;
+ private String author;
+ private String description;
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED, boost = @Boost(2.0F))
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
\ No newline at end of file
Added: search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/boost/BoostedGetDescriptionLibrary.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -0,0 +1,67 @@
+package org.hibernate.search.test.query.boost;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author John Griffin
+ */
+@Entity
+@Indexed
+@Analyzer(impl = StandardAnalyzer.class)
+public class BoostedGetDescriptionLibrary {
+ private int id;
+ private String title;
+ private String author;
+ private String description;
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Boost(2.0F)
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
\ No newline at end of file
Added: search/trunk/src/test/org/hibernate/search/test/query/boost/FieldBoostTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/boost/FieldBoostTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/boost/FieldBoostTest.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -0,0 +1,196 @@
+package org.hibernate.search.test.query.boost;
+
+import java.util.List;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author John Griffin
+ */
+public class FieldBoostTest extends SearchTestCase {
+
+ public void testBoostedGetDesc() throws Exception {
+ FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
+ buildBoostedGetIndex( fullTextSession );
+
+ fullTextSession.clear();
+ Transaction tx = fullTextSession.beginTransaction();
+
+ QueryParser authorParser = new QueryParser( "author", new StandardAnalyzer() );
+ QueryParser descParser = new QueryParser( "description", new StandardAnalyzer() );
+ Query author = authorParser.parse( "Wells" );
+ Query desc = descParser.parse( "martians" );
+
+ BooleanQuery query = new BooleanQuery();
+ query.add( author, BooleanClause.Occur.SHOULD );
+ query.add( desc, BooleanClause.Occur.SHOULD );
+ //System.out.println( query.toString() );
+
+ org.hibernate.search.FullTextQuery hibQuery =
+ fullTextSession.createFullTextQuery( query, BoostedGetDescriptionLibrary.class );
+ List results = hibQuery.list();
+
+ //System.out.println( hibQuery.explain( 0 ) );
+ //System.out.println( hibQuery.explain( 1 ) );
+
+ assertTrue(
+ "incorrect document returned",
+ ( ( BoostedGetDescriptionLibrary ) results.get( 0 ) ).getDescription().startsWith( "Martians" )
+ );
+
+ //cleanup
+ for ( Object element : fullTextSession.createQuery( "from " + BoostedGetDescriptionLibrary.class.getName() )
+ .list() ) {
+ fullTextSession.delete( element );
+ }
+ tx.commit();
+ fullTextSession.close();
+ }
+
+ public void testBoostedFieldDesc() throws Exception {
+ FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
+ buildBoostedFieldIndex( fullTextSession );
+
+ fullTextSession.clear();
+ Transaction tx = fullTextSession.beginTransaction();
+
+ QueryParser authorParser = new QueryParser( "author", new StandardAnalyzer() );
+ QueryParser descParser = new QueryParser( "description", new StandardAnalyzer() );
+ Query author = authorParser.parse( "Wells" );
+ Query desc = descParser.parse( "martians" );
+
+ BooleanQuery query = new BooleanQuery();
+ query.add( author, BooleanClause.Occur.SHOULD );
+ query.add( desc, BooleanClause.Occur.SHOULD );
+ //System.out.println( query.toString() );
+
+ org.hibernate.search.FullTextQuery hibQuery =
+ fullTextSession.createFullTextQuery( query, BoostedFieldDescriptionLibrary.class );
+ List results = hibQuery.list();
+
+ assertTrue(
+ "incorrect document boost",
+ ( ( BoostedFieldDescriptionLibrary ) results.get( 0 ) ).getDescription().startsWith( "Martians" )
+ );
+
+ //System.out.println( hibQuery.explain( 0 ) );
+ //System.out.println( hibQuery.explain( 1 ) );
+
+ //cleanup
+ for ( Object element : fullTextSession.createQuery( "from " + BoostedFieldDescriptionLibrary.class.getName() )
+ .list() ) {
+ fullTextSession.delete( element );
+ }
+ tx.commit();
+ fullTextSession.close();
+ }
+
+ public void testBoostedDesc() throws Exception {
+ FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
+ buildBoostedDescIndex( fullTextSession );
+
+ fullTextSession.clear();
+ Transaction tx = fullTextSession.beginTransaction();
+
+ QueryParser authorParser = new QueryParser( "author", new StandardAnalyzer() );
+ QueryParser descParser = new QueryParser( "description", new StandardAnalyzer() );
+ Query author = authorParser.parse( "Wells" );
+ Query desc = descParser.parse( "martians" );
+
+ BooleanQuery query = new BooleanQuery();
+ query.add( author, BooleanClause.Occur.SHOULD );
+ query.add( desc, BooleanClause.Occur.SHOULD );
+ //System.out.println( query.toString() );
+
+ org.hibernate.search.FullTextQuery hibQuery =
+ fullTextSession.createFullTextQuery( query, BoostedDescriptionLibrary.class );
+ List results = hibQuery.list();
+
+ //System.out.println( hibQuery.explain( 0 ) );
+ //System.out.println( hibQuery.explain( 1 ) );
+
+ assertTrue(
+ "incorrect document returned",
+ ( ( BoostedDescriptionLibrary ) results.get( 0 ) ).getDescription().startsWith( "Martians" )
+ );
+
+ //cleanup
+ for ( Object element : fullTextSession.createQuery( "from " + BoostedDescriptionLibrary.class.getName() )
+ .list() ) {
+ fullTextSession.delete( element );
+ }
+ tx.commit();
+ fullTextSession.close();
+ }
+
+ private void buildBoostedDescIndex(FullTextSession session) {
+ Transaction tx = session.beginTransaction();
+ BoostedDescriptionLibrary l = new BoostedDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "The Invisible Man" );
+ l.setDescription( "Scientist discovers invisibility and becomes insane." );
+ session.save( l );
+
+ session.save( l );
+ l = new BoostedDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "War of the Worlds" );
+ l.setDescription( "Martians invade earth to eliminate mankind." );
+ session.save( l );
+
+ tx.commit();
+ }
+
+ private void buildBoostedFieldIndex(FullTextSession session) {
+ Transaction tx = session.beginTransaction();
+ BoostedFieldDescriptionLibrary l = new BoostedFieldDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "The Invisible Man" );
+ l.setDescription( "Scientist discovers invisibility and becomes insane." );
+ session.save( l );
+
+ session.save( l );
+ l = new BoostedFieldDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "War of the Worlds" );
+ l.setDescription( "Martians invade earth to eliminate mankind." );
+ session.save( l );
+
+ tx.commit();
+ }
+
+ private void buildBoostedGetIndex(FullTextSession session) {
+ Transaction tx = session.beginTransaction();
+ BoostedGetDescriptionLibrary l = new BoostedGetDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "The Invisible Man" );
+ l.setDescription( "Scientist discovers invisibility and becomes insane." );
+ session.save( l );
+
+ session.save( l );
+ l = new BoostedGetDescriptionLibrary();
+ l.setAuthor( "H.G. Wells" );
+ l.setTitle( "War of the Worlds" );
+ l.setDescription( "Martians invade earth to eliminate mankind." );
+ session.save( l );
+
+ tx.commit();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ BoostedDescriptionLibrary.class,
+ BoostedFieldDescriptionLibrary.class,
+ BoostedGetDescriptionLibrary.class,
+ };
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/query/boost/Library.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/boost/Library.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/boost/Library.java 2008-10-24 17:42:28 UTC (rev 15389)
@@ -0,0 +1,61 @@
+package org.hibernate.search.test.query.boost;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author John Griffin
+ */
+@Entity
+@Indexed
+public class Library {
+ private int id;
+ private String title;
+ private String author;
+ private String Description;
+
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Field(store = Store.YES, index = Index.TOKENIZED)
+ public String getDescription() {
+ return Description;
+ }
+
+ public void setDescription(String description) {
+ Description = description;
+ }
+}
\ No newline at end of file
15 years, 6 months
Hibernate SVN: r15388 - in search/trunk: src/java/org/hibernate/search and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-10-24 11:48:35 -0400 (Fri, 24 Oct 2008)
New Revision: 15388
Modified:
search/trunk/changelog.txt
search/trunk/ivy.xml
search/trunk/pom.xml
search/trunk/src/java/org/hibernate/search/Version.java
Log:
HSEARCH-286 Update to latest GA versions of dependencies.
Update version number
Modified: search/trunk/changelog.txt
===================================================================
--- search/trunk/changelog.txt 2008-10-24 15:04:07 UTC (rev 15387)
+++ search/trunk/changelog.txt 2008-10-24 15:48:35 UTC (rev 15388)
@@ -1,6 +1,10 @@
Hibernate Search Changelog
==========================
+3.1.0.Beta2 (27-09-2008)
+------------------------
+
+
3.1.0.Beta1 (17-07-2008)
------------------------
Modified: search/trunk/ivy.xml
===================================================================
--- search/trunk/ivy.xml 2008-10-24 15:04:07 UTC (rev 15387)
+++ search/trunk/ivy.xml 2008-10-24 15:48:35 UTC (rev 15388)
@@ -15,9 +15,9 @@
<!-- compile time dependencies -->
<dependency name="ejb3-persistence" rev="1.0.2.GA" conf="default->default"/>
- <dependency name="commons-annotations" rev="3.1.0.CR1" conf="default->default"/>
+ <dependency name="commons-annotations" rev="3.1.0.GA" conf="default->default"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.4.2" conf="default->default"/>
- <dependency org="org.hibernate" name="hibernate-core" rev="3.3.0.CR2" conf="default->default"/>
+ <dependency org="org.hibernate" name="hibernate-core" rev="3.3.1.GA" conf="default->default"/>
<dependency org="javax.transaction" name="jta" rev="1.1" conf="default->default"/>
<dependency org="org.apache.lucene" name="lucene-core" rev="2.4.0" conf="default->default"/>
<dependency org="javax.jms" name="jms" rev="1.1" conf="default->default"/> <!-- optional -->
@@ -33,8 +33,8 @@
<dependency org="dom4j" name="dom4j" rev="1.6.1" conf="test->default"/>
<!-- test deps -->
- <dependency name="annotations" rev="3.4.0.CR2" conf="test->default"/>
- <dependency name="entitymanager" rev="3.4.0.CR1" conf="test->default"/>
+ <dependency name="annotations" rev="3.4.0.GA" conf="test->default"/>
+ <dependency name="entitymanager" rev="3.4.0.GA" conf="test->default"/>
<dependency org="cglib" name="cglib" rev="2.1_3" conf="test->default"/>
<dependency org="asm" name="asm" rev="1.5.3" conf="test->default"/>
<dependency org="asm" name="asm-attrs" rev="1.5.3" conf="test->default"/>
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2008-10-24 15:04:07 UTC (rev 15387)
+++ search/trunk/pom.xml 2008-10-24 15:48:35 UTC (rev 15388)
@@ -10,12 +10,12 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>3.3.0.CR1</version>
+ <version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
- <version>3.1.0.CR1</version>
+ <version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -42,13 +42,13 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
- <version>3.4.0.CR1</version>
+ <version>3.4.0.GA</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.4.0.CR1</version>
+ <version>3.4.0.GA</version>
<optional>true</optional>
</dependency>
<dependency>
Modified: search/trunk/src/java/org/hibernate/search/Version.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/Version.java 2008-10-24 15:04:07 UTC (rev 15387)
+++ search/trunk/src/java/org/hibernate/search/Version.java 2008-10-24 15:48:35 UTC (rev 15388)
@@ -12,7 +12,7 @@
* @author Emmanuel Bernard
*/
public class Version {
- public static final String VERSION = "3.1.0.SNAPSHOT" + new Date();
+ public static final String VERSION = "3.1.0.Beta2";
private static final Logger log = LoggerFactory.make();
15 years, 6 months
Hibernate SVN: r15387 - in search/trunk/src: test/org/hibernate/search/test/query and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-10-24 11:04:07 -0400 (Fri, 24 Oct 2008)
New Revision: 15387
Modified:
search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/test/org/hibernate/search/test/query/QueryUnindexedEntityTest.java
Log:
HSEARCH-162 - added a check to verify that at least one document builder (index class) exists
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-10-24 14:22:27 UTC (rev 15386)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-10-24 15:04:07 UTC (rev 15387)
@@ -323,28 +323,28 @@
if ( filterDefinitions == null || filterDefinitions.size() == 0 ) {
return; // there is nothing to do if we don't have any filter definitions
}
-
+
ChainedFilter chainedFilter = new ChainedFilter();
for (FullTextFilterImpl fullTextFilter : filterDefinitions.values()) {
Filter filter = buildLuceneFilter(fullTextFilter);
chainedFilter.addFilter( filter );
}
-
+
if ( filter != null ) chainedFilter.addFilter( filter );
filter = chainedFilter;
}
/**
* Builds a Lucene filter using the given <code>FullTextFilter</code>.
- *
- * @param fullTextFilter the Hibernate specific <code>FullTextFilter</code> used to create the
+ *
+ * @param fullTextFilter the Hibernate specific <code>FullTextFilter</code> used to create the
* Lucene <code>Filter</code>.
* @return the Lucene filter mapped to the filter definition
*/
private Filter buildLuceneFilter(FullTextFilterImpl fullTextFilter) {
-
+
SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
-
+
/*
* FilterKey implementations and Filter(Factory) do not have to be threadsafe wrt their parameter injection
* as FilterCachingStrategy ensure a memory barrier between concurrent thread calls
@@ -357,10 +357,10 @@
Filter filter = cacheInstance( def.getCacheMode() ) ?
searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
null;
-
+
if ( filter == null ) {
- filter = createFilter(def, instance);
-
+ filter = createFilter(def, instance);
+
// add filter to cache if we have to
if ( cacheInstance( def.getCacheMode() ) ) {
searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
@@ -398,17 +398,17 @@
+ (def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : ""), e );
}
}
-
+
filter = addCachingWrapperFilter(filter, def);
return filter;
}
/**
* Decides whether to wrap the given filter around a <code>CachingWrapperFilter<code>.
- *
+ *
* @param filter the filter which maybe gets wrapped.
* @param def The filter definition used to decide whether wrapping should occur or not.
- * @return The original filter or wrapped filter depending on the information extracted from
+ * @return The original filter or wrapped filter depending on the information extracted from
* <code>def</code>.
*/
private Filter addCachingWrapperFilter(Filter filter, FilterDef def) {
@@ -416,7 +416,7 @@
int cachingWrapperFilterSize = getSearchFactoryImplementor().getFilterCacheBitResultsSize();
filter = new org.hibernate.search.filter.CachingWrapperFilter(filter, cachingWrapperFilterSize);
}
-
+
return filter;
}
@@ -425,7 +425,7 @@
if ( !cacheInstance( def.getCacheMode() ) ) {
return key; // if the filter is not cached there is no key!
}
-
+
if ( def.getKeyMethod() == null ) {
key = new FilterKey() {
public int hashCode() {
@@ -534,7 +534,12 @@
Similarity searcherSimilarity = null;
//TODO check if caching this work for the last n list of classes makes a perf boost
if ( classes == null || classes.length == 0 ) {
- //no class means all classes
+ // empty classes array means search over all indexed enities,
+ // but we have to make sure there is at least one
+ if ( builders.isEmpty() ) {
+ throw new HibernateException( "There are no mapped entities (don't forget to add @Indexed to at least one class)." );
+ }
+
for (DocumentBuilder builder : builders.values()) {
searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
Modified: search/trunk/src/test/org/hibernate/search/test/query/QueryUnindexedEntityTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/QueryUnindexedEntityTest.java 2008-10-24 14:22:27 UTC (rev 15386)
+++ search/trunk/src/test/org/hibernate/search/test/query/QueryUnindexedEntityTest.java 2008-10-24 15:04:07 UTC (rev 15387)
@@ -38,7 +38,7 @@
fail();
}
catch ( HibernateException e ) {
- assertTrue( "Wrong message", e.getMessage().startsWith( "Not a mapped entity" ) );
+ assertTrue( "Wrong message", e.getMessage().startsWith( "There are no mapped entities" ) );
}
tx.rollback();
15 years, 6 months