queryBuilder .keyword() .onFields("name", "city", "email") .matching(text) .createQuery();
QueryBuilder queryBuilder = getFullTextQueryBuilder(); MustJunction termination = queryBuilder.bool() .must(queryBuilder.keyword().onFields(CommonUtils.empty(tagId) ? textFields : tagFields) .matching(CommonUtils.empty(tagId) ? text : tagId).createQuery()) .must(new TermQuery(new Term("siteId", siteId.toString())));
QueryBuilder queryBuilder = getFullTextQueryBuilder(); MustJunction termination = queryBuilder.bool() .must(queryBuilder.keyword().onFields(CommonUtils.empty(tagId) ? textFields : tagFields) .matching(CommonUtils.empty(tagId) ? text : tagId).createQuery()) .must(new TermQuery(new Term("siteId", siteId.toString())));
QueryBuilder queryBuilder = getFullTextQueryBuilder(); MustJunction termination = queryBuilder.bool() .must(queryBuilder.keyword().onFields(CommonUtils.empty(tagIds) ? textFields : tagFields) .matching(CommonUtils.empty(tagIds) ? text : tagIds).createQuery()) .must(new TermQuery(new Term("siteId", siteId.toString())));
QueryBuilder queryBuilder = getFullTextQueryBuilder(); MustJunction termination = queryBuilder.bool() .must(queryBuilder.keyword().onFields(CommonUtils.empty(tagIds) ? textFields : tagFields) .matching(CommonUtils.empty(tagIds) ? text : tagIds).createQuery()) .must(new TermQuery(new Term("siteId", siteId.toString())));
.onFields("description", "name", "comments.text", "properties.key", "properties.value") .andField("content").ignoreFieldBridge() .andField("contentPath").ignoreFieldBridge()
@Test public void testMultipleFields() throws Exception { final QueryBuilder monthQb = helper.queryBuilder( Month.class ); //combined query, January and February both contain whitening but February in a longer text Query query = monthQb.keyword() .onField( "mythology" ) .andField( "history" ) .matching( "whitening" ) .createQuery(); helper.assertThat( query ).from( Month.class ).matchesExactlyIds( 1, 2 ); //combined query, January and February both contain whitening but February in a longer text query = monthQb.keyword() .onFields( "mythology", "history" ) .boostedTo( 30 ) .matching( "whitening" ).createQuery(); helper.assertThat( query ).from( Month.class ).matchesExactlyIds( 1, 2 ); //boosted query, January and February both contain whitening but February in a longer text //since history is boosted, February should come first though query = monthQb.keyword() .onField( "mythology" ) .andField( "history" ) .boostedTo( 30 ) .matching( "whitening" ) .createQuery(); helper.assertThat( query ).from( Month.class ).matchesExactlyIds( 2, 1 ); }