Compass和Lucene的一些資料

Spring Compass (Lucene) 全文本搜索排序問題

http://osacar.iteye.com/blog/1050899

 

Apache Lucene - Query Parser Syntax

http://lucene.apache.org/core/3_6_1/queryparsersyntax.html


Compass - Java Search Engine Framework 
Reference Documentation

http://www.compass-project.org/docs/latest/reference/html/index.html


compass 中的 @SearchableComponent SearchableReference 的區別 ,及對象導航查詢

http://blog.csdn.net/jixiuffff/article/details/5526791


Lucene、Compass學習以及與SSH的整合

http://blog.csdn.net/ygj26/article/details/5552059


Compass學習筆記3

http://www.blogjava.net/bjwulin/archive/2007/09/13/85013.html

通用元數據提供了將元數據名稱和別名定義從osem文件提取到外面的方式。當你的應用程序有大量的域模型時尤其有用。另外一個優勢就是添加額外的信息倒元數據中,不如描述。也能制定元數據定義的格式,這樣就不用在osem 文件中定義了 。
通過集中話元數據,其它工具也能更好地利用這些信息。
OSEM文件引用通用元數據的方式是採用${}.

query syntax:
jack :缺省的查詢域中包括jack字段。
jack london:缺省的查詢域中包括 jack 或 london, 或者2者都有。
+jack +london: 缺省的查詢域中必須包括jack和london。
name:jack:name字段中包括jack。
name:jack -city:london :name字段中包括jack但是city字段中不包括london。
name:"jack london" :name字段中包括jack london短語。
name:"jack london"~5 :name字段包括至少5次jack and london短語
jack* 包含以jack開頭的詞條。
jack~ 包括以jack結尾的詞條。
birthday:[1870/01/01 TO 1920/01/01] birthday從1870-01-01到1920-01-01。


CompassHits, CompassDetachedHits & CompassHitsOperations:
compassHits:所有的搜索結果都是通過該接口訪問。只能用在事務上下文中。如果脫離上下文,則需要detached。compassHits和compassDetachedHits都共享相同的操作接口:compassHitsOperation。

getLength() or length() :得到搜索資源的長度
score(n) 第n個搜索資源的分值。
resource(n) 第n個搜索資源
data(n) 第n個對象實例。

CompassQuery and CompassQueryBuilder:
CompassQueryBuilder提供了程序創建compassQuery的功能。compassQuery能夠用來添加排序和執行查詢。
CompassHits hits = session.createQueryBuilder()
.queryString("+name:jack +familyName:london")
.setAnalyzer("an1") // use a different analyzer
.toQuery()
.addSort("familyName", CompassQuery.SortPropertyType.STRING)
.addSort("birthdate", CompassQuery.SortPropertyType.INT)
.hits();

CompassQueryBuilder queryBuilder = session.createQueryBuilder();
CompassHits hits = queryBuilder.bool()
.addMust( queryBuilder.term("name", "jack") )
.addMustNot( queryBuilder.term("familyName", "london") )
.toQuery()
.addSort("familyName", CompassQuery.SortPropertyType.STRING)
.addSort("birthdate", CompassQuery.SortPropertyType.INT)
.hits();

注意排序的屬性必須是un_tokenized。

OSEM映射文件:
<class name="eg.A" alias="a">
<id name="id" />
<property name="familyName">
<meta-data>family-name</meta-data>
</property>
<property name="date">
<meta-data converter-param="YYYYMMDD">date-sem</meta-data>
</property>
Working with objects
Compass - Java Search Engine 78
</class>
查詢方式:採用compassQueryBuilder,許多查詢可以直接工作在mapping的層次上。
CompassQueryBuilder queryBuilder = session.createQueryBuilder();
CompassHits hits = queryBuilder.term("a.familyName.family-name", "london").hits();
// 採用類屬性的元數據id, 在上面的例子中將採用第一個元數據.
CompassHits hits = queryBuilder.term("a.familyName", "london").hits();
//查詢編輯器將會採用相應的轉化器轉換數據。
CompassHits hits = queryBuilder.term("a.date.date-sem", new Date()).hits();
CompassHits hits = queryBuilder.bool()
.addMust( queryBuilder.alias("a") )
.addMust( queryBuilder.term("a.familyName", "london") )
.toQuery().hits();

CompassHighlighter:提供高亮度匹配搜索的文字字段。
CompassHits hits = session.find("london");
String fragment = hits.highlighter(0).fragment("description");
高亮度只能用於CompassHits,只能用在事務上下文中。

在detachedHits中使用高亮度:
CompassHits hits = session.find("london");
//在事務上下文中處理高亮度。
for (int i = 0.; i < 10; i++) {
hits.highlighter(i).fragment("description"); // this will cache the highlighted fragment
}
CompassHit[] detachedHits = hits.detach(0, 10).getHits();
// outside of a transaction (maybe in a view technology)
for (int i = 0; i < detachedHits.length; i++) {
// this will return the first fragment
detachedHits[i].getHighlightedText().getHighlightedText();
// this will return the description fragment, note that the implementation
// implements the Map interface, which allows it to be used simply in JSTL env and others
detachedHits[i].getHighlightedText().getHighlightedText("description");
}


Compass and Grails how to

http://grails.org/Compass+and+Grails+how+to



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章