Search in sources :

Example 6 with ExtendedCommonTermsQuery

use of org.apache.lucene.queries.ExtendedCommonTermsQuery in project elasticsearch by elastic.

the class CommonTermsQueryBuilderTests method testCommonTermsQuery1.

public void testCommonTermsQuery1() throws IOException {
    String query = copyToStringFromClasspath("/org/elasticsearch/index/query/commonTerms-query1.json");
    Query parsedQuery = parseQuery(query).toQuery(createShardContext());
    assertThat(parsedQuery, instanceOf(ExtendedCommonTermsQuery.class));
    ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
    assertThat(ectQuery.getHighFreqMinimumNumberShouldMatchSpec(), nullValue());
    assertThat(ectQuery.getLowFreqMinimumNumberShouldMatchSpec(), equalTo("2"));
}
Also used : Query(org.apache.lucene.search.Query) QueryBuilders.commonTermsQuery(org.elasticsearch.index.query.QueryBuilders.commonTermsQuery) ExtendedCommonTermsQuery(org.apache.lucene.queries.ExtendedCommonTermsQuery) ExtendedCommonTermsQuery(org.apache.lucene.queries.ExtendedCommonTermsQuery)

Example 7 with ExtendedCommonTermsQuery

use of org.apache.lucene.queries.ExtendedCommonTermsQuery in project elasticsearch by elastic.

the class CommonTermsQueryBuilderTests method testCommonTermsQuery4.

// see #11730
public void testCommonTermsQuery4() throws IOException {
    boolean disableCoord = randomBoolean();
    Query parsedQuery = parseQuery(commonTermsQuery("field", "text").disableCoord(disableCoord)).toQuery(createShardContext());
    assertThat(parsedQuery, instanceOf(ExtendedCommonTermsQuery.class));
    ExtendedCommonTermsQuery ectQuery = (ExtendedCommonTermsQuery) parsedQuery;
    assertThat(ectQuery.isCoordDisabled(), equalTo(disableCoord));
}
Also used : Query(org.apache.lucene.search.Query) QueryBuilders.commonTermsQuery(org.elasticsearch.index.query.QueryBuilders.commonTermsQuery) ExtendedCommonTermsQuery(org.apache.lucene.queries.ExtendedCommonTermsQuery) ExtendedCommonTermsQuery(org.apache.lucene.queries.ExtendedCommonTermsQuery)

Aggregations

ExtendedCommonTermsQuery (org.apache.lucene.queries.ExtendedCommonTermsQuery)7 Query (org.apache.lucene.search.Query)5 QueryBuilders.commonTermsQuery (org.elasticsearch.index.query.QueryBuilders.commonTermsQuery)4 MappedFieldType (org.elasticsearch.index.mapper.MappedFieldType)2 Analyzer (org.apache.lucene.analysis.Analyzer)1 BooleanClause (org.apache.lucene.search.BooleanClause)1 Occur (org.apache.lucene.search.BooleanClause.Occur)1 BooleanQuery (org.apache.lucene.search.BooleanQuery)1 BoostQuery (org.apache.lucene.search.BoostQuery)1 FuzzyQuery (org.apache.lucene.search.FuzzyQuery)1 IndexOrDocValuesQuery (org.apache.lucene.search.IndexOrDocValuesQuery)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)1 PhraseQuery (org.apache.lucene.search.PhraseQuery)1 PointRangeQuery (org.apache.lucene.search.PointRangeQuery)1 TermQuery (org.apache.lucene.search.TermQuery)1 MultiPhrasePrefixQuery (org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery)1 MatchQuery (org.elasticsearch.index.search.MatchQuery)1 ZeroTermsQuery (org.elasticsearch.index.search.MatchQuery.ZeroTermsQuery)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1