2014-07-10 219 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(); 
} 

打印

测试
散列


除去