本文整理匯總了Java中org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilders.matchPhraseQuery方法的具體用法?Java QueryBuilders.matchPhraseQuery怎麽用?Java QueryBuilders.matchPhraseQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.index.query.QueryBuilders
的用法示例。
在下文中一共展示了QueryBuilders.matchPhraseQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
* Here to establish QueryBuilder patterns
*/
void test() {
SearchSourceBuilder b;
BoolQueryBuilder qb = QueryBuilders.boolQuery();
QueryBuilder qbmm = QueryBuilders.multiMatchQuery("name", "fieldNames");
QueryBuilder qbm = QueryBuilders.matchQuery("name", "text");
QueryBuilder qbmp = QueryBuilders.matchPhraseQuery("name", "text");
QueryBuilder qb1 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_SUBJECT_PROPERTY, "");
QueryBuilder qb2 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_OBJECT_PROPERTY, "");
QueryBuilder qb3 = QueryBuilders.termQuery(ITQCoreOntology.INSTANCE_OF_PROPERTY_TYPE, "");
qb.must(qb3);
qb.should(qb1);
qb.should(qb2);
QueryBuilder partial = QueryBuilders.regexpQuery("name", "regexp");
QueryBuilder wildcard = QueryBuilders.wildcardQuery("name", "query");
}
示例2: test
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
@Test
public void test() throws Exception {
String key = "this is a";
MatchPhraseQueryBuilder matchPhraseQueryBuilder = QueryBuilders.matchPhraseQuery("title",key);
matchPhraseQueryBuilder.boost(10);
matchPhraseQueryBuilder.analyzer("standard");
matchPhraseQueryBuilder.slop(2);
SearchResponse searchResponse = client.prepareSearch()
.setIndices("my_index")
.setTypes("my_type")
.setQuery(matchPhraseQueryBuilder)
.execute()
.actionGet();
}
示例3: fullTextQuerySingleField
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
public String fullTextQuerySingleField(String textQuery, boolean isPhraseQuery,
String fieldName, int start, int count) {
QueryBuilder qb;
if (!isPhraseQuery)
qb = QueryBuilders.matchQuery(fieldName, textQuery);
else
qb = QueryBuilders.matchPhraseQuery(fieldName, textQuery);
SearchSourceBuilder ssb = new SearchSourceBuilder();
ssb.query(qb);
ssb.from(start);
if (count > -1)
ssb.size(count);
return ssb.toString();
}