WEB开发网
开发学院软件开发Java 再谈compass----集成站内搜索 阅读

再谈compass----集成站内搜索

 2009-09-21 00:00:00 来源:WEB开发网   
核心提示: 这里要特别注意有集合类型要搜索或显示的时候,两边定义的@SearchableReference或 @SearchableComponent必须一致 2.再spring的配置文件中加入以下代码 Java代码<beanid="annotationConfiguration"

这里要特别注意有集合类型要搜索或显示的时候,两边定义的@SearchableReference或 @SearchableComponent必须一致

2.再spring的配置文件中加入以下代码

Java代码   

<bean id="annotationConfiguration" class="org.compass.annotations.config.CompassAnnotationsConfiguration"> 
</bean> 
 <!-- compass Bean --> 
<bean id="compass" class="org.compass.spring.LocalCompassBean"> 
 <property name="compassConfiguration" 
  ref="annotationConfiguration" /> 
 <property name="transactionManager" ref="txManager" /> 
 <property name="compassSettings"> 
  <props> 
 <!-- 定义索引的存储位置 --> 
<prop key="compass.engine.connection">d:/compass</prop> 
<prop key="compass.transaction.factory"> 
   org.compass.spring.transaction.SpringSyncTransactionFactory 
</prop> 
 <!-- 定义分词器--> 
<prop key="compass.engine.analyzer.MMAnalyzer.CustomAnalyzer"> 
org.mira.lucene.analysis.IK_CAnalyzer 
</prop> 
</props> 
</property> 
    <property name="resourceDirectoryLocations"> 
  <list> 
  <value>classpath:net/shopin/bean/product</value> 
  </list> 
 </property> 
 
 </bean> 
 
 <bean id="jpaGpsDevice" 
 class="org.compass.gps.device.jpa.JpaGpsDevice"> 
 <property name="name"> 
  <value>JpaGpsDevice</value> 
 </property> 
 <property name="entityManagerFactory" 
  ref="entityManagerFactory" /> 
 <property name="mirrorDataChanges"> 
  <value>true</value> 
 </property> 
 </bean> 
 <!-- 数据库中的数据变化后同步更新索引 --> 
 <bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps" 
 init-method="start" destroy-method="stop"> 
 <property name="compass" ref="compass" /> 
 <property name="gpsDevices"> 
  <list> 
  <bean 
   class="org.compass.spring.device.SpringSyncTransactionGpsDeviceWrapper"> 
   <property name="gpsDevice" ref="jpaGpsDevice" /> 
  </bean> 
  </list> 
 </property> 
 </bean> 
 
 
 <bean id="compassTemplate" 
 class="org.compass.core.CompassTemplate"> 
 <property name="compass" ref="compass" /> 
 </bean> 
 
 <!-- 定时重建索引(利用quartz)或随Spring ApplicationContext启动而重建索引 --> 
 <bean id="compassIndexBuilder" 
 class="net.shopin.service.search.impl.CompassIndexBuilder" 
 lazy-init="false"> 
 <property name="compassGps" ref="compassGps" /> 
 <property name="buildIndex" value="true" /> 
 <property name="lazyTime" value="5" /> 
 </bean> 

上一页  1 2 3 4 5 6 7  下一页

Tags:compass 集成 搜索

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接