当前位置: 代码迷 >> J2EE >> 学习compass遇到困难了,搞了三天头都要炸了解决办法
  详细解决方案

学习compass遇到困难了,搞了三天头都要炸了解决办法

热度:97   发布时间:2016-04-22 01:24:10.0
学习compass遇到困难了,搞了三天头都要炸了
看了下lucene,后来看到compass这个框架。
现在在做一个图书的搜索实现,在做检索的时候发现compass不支持cascade   ,
高手指点下吧   ,不然又要“流产”了

  book.cmp.xml
=======================================================================
<?xml   version= "1.0 "?>
<!DOCTYPE   compass-core-mapping   PUBLIC  
        "-//Compass/Compass   Core   Mapping   DTD   1.0//EN "
        "http://www.opensymphony.com/compass/dtd/compass-core-mapping.dtd ">
<compass-core-mapping   package= "com.jlive.search.beans ">
<class   name= "Book "   alias= "book ">

<id   name= "id "   />

 

<property   name= "bookname ">

<meta-data> bookname </meta-data>

</property>
<property   name= "contents ">

<meta-data> contents </meta-data>

</property>

<property   name= "publication ">

<meta-data> publication </meta-data>

</property>

<property   name= "publicationdate ">

<meta-data> publicationdate </meta-data>

</property>
<component   name= "author "   cascade= "all "   ref-alias= "author "/>


</class>


</compass-core-mapping>


author.cpm.xml
=====================================================================
<?xml   version= "1.0 "?>
<!DOCTYPE   compass-core-mapping   PUBLIC  
        "-//Compass/Compass   Core   Mapping   DTD   1.0//EN "
        "http://www.opensymphony.com/compass/dtd/compass-core-mapping.dtd ">
<compass-core-mapping   package= "com.jlive.search.beans ">
<class   name= "Authors "   alias= "author ">

<id   name= "id "   />

<property   name= "introduction ">

<meta-data> introduction </meta-data>

</property>
<reference   name= "books "   cascade= "all "   ref-alias= "book "/>
<property   name= "authorname ">

<meta-data> authorname </meta-data>

</property>
<property   name= "telephone ">

<meta-data> telephone </meta-data>

</property>
</class>


</compass-core-mapping>

=======================================================================
compass   =   (Compass)   ApplicationContextUtil.getFactory().getBean(
"compass ");
CompassTemplate   template   =   new   CompassTemplate(compass);

template.execute(new   CompassCallbackWithoutResult()   {
protected   void   doInCompassWithoutResult(CompassSession   session)
throws   CompassException   {

CompassQueryBuilder   queryBuilder   =   session.queryBuilder();
//   The   following   search   will   result   in   matching   "london "   against
  相关解决方案