2014-07-10 87 views
0

我想要做CQS QueryBuilder的一個全文檢索:使用特殊字符

type=cq:Page 
path=/content/page 
fulltext=#Employees 

嘗試這給了我打的字「員工」匹配,即使我有哈希作爲查詢的一部分'#僱員'。

看不到的QueryBuilder修改查詢,但有可能的是Lucene的刪除哈希?

回答

2

我不確定cq5,但是如果使用StandardAnalyzer,那麼在標記和查詢時,Lucene確實會刪除哈希鍵,按照Word boundary rules from Unicode standard annex UAX#29

此代碼

public static void main(String[] args) throws IOException { 
    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_46); 
    String s = "test if #hash has been removed"; 
    TokenStream stream = analyzer.tokenStream("field", new StringReader(s)); 
    stream.reset(); 
    CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class); 
    while (stream.incrementToken()) { 
     System.out.println(termAtt.toString()); 
    } 
    stream.end(); 
    stream.close(); 
} 

打印

測試
散列


除去