Search in sources :

Example 1 with SimpleQueryStringBuilder

use of org.opensearch.index.query.SimpleQueryStringBuilder in project OpenSearch by opensearch-project.

the class DisableGraphQueryTests method testSimpleQueryString.

public void testSimpleQueryString() throws IOException {
    SimpleQueryStringBuilder builder = new SimpleQueryStringBuilder("foo bar baz");
    builder.field("text_shingle_unigram");
    builder.flags(SimpleQueryStringFlag.NONE);
    Query query = builder.toQuery(shardContext);
    assertThat(expectedQueryWithUnigram, equalTo(query));
    builder = new SimpleQueryStringBuilder("\"foo bar baz\"");
    builder.field("text_shingle_unigram");
    builder.flags(SimpleQueryStringFlag.PHRASE);
    query = builder.toQuery(shardContext);
    assertThat(expectedPhraseQueryWithUnigram, equalTo(query));
    builder = new SimpleQueryStringBuilder("foo bar baz biz");
    builder.field("text_shingle");
    builder.flags(SimpleQueryStringFlag.NONE);
    query = builder.toQuery(shardContext);
    assertThat(expectedQuery, equalTo(query));
    builder = new SimpleQueryStringBuilder("\"foo bar baz biz\"");
    builder.field("text_shingle");
    builder.flags(SimpleQueryStringFlag.PHRASE);
    query = builder.toQuery(shardContext);
    assertThat(expectedPhraseQuery, equalTo(query));
}
Also used : Query(org.apache.lucene.search.Query) PhraseQuery(org.apache.lucene.search.PhraseQuery) MultiPhraseQuery(org.apache.lucene.search.MultiPhraseQuery) TermQuery(org.apache.lucene.search.TermQuery) SynonymQuery(org.apache.lucene.search.SynonymQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) MatchQuery(org.opensearch.index.search.MatchQuery) SimpleQueryStringBuilder(org.opensearch.index.query.SimpleQueryStringBuilder)

Aggregations

BooleanQuery (org.apache.lucene.search.BooleanQuery)1 MultiPhraseQuery (org.apache.lucene.search.MultiPhraseQuery)1 PhraseQuery (org.apache.lucene.search.PhraseQuery)1 Query (org.apache.lucene.search.Query)1 SynonymQuery (org.apache.lucene.search.SynonymQuery)1 TermQuery (org.apache.lucene.search.TermQuery)1 SimpleQueryStringBuilder (org.opensearch.index.query.SimpleQueryStringBuilder)1 MatchQuery (org.opensearch.index.search.MatchQuery)1