protected Query pq(float boost, int slop, String field, String... texts) { PhraseQuery query = new PhraseQuery(); for (String text : texts) { query.add(new Term(field, text)); } query.setBoost(boost); query.setSlop(slop); return query; }
public void testCJKBoostedPhrase() throws Exception { // individual CJK chars as terms StandardAnalyzer analyzer = new StandardAnalyzer(TEST_VERSION_CURRENT); PhraseQuery expected = new PhraseQuery(); expected.setBoost(0.5f); expected.add(new Term("field", "中")); expected.add(new Term("field", "国")); assertEquals(expected, getQuery("\"中国\"^0.5", analyzer)); }