Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Adapt QueryStringQueryBuilderTests expectations #32236

Merged
merged 2 commits into from
Jul 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.lucene.analysis.MockSynonymAnalyzer;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.BlendedTermQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
Expand Down Expand Up @@ -382,10 +383,11 @@ public QueryStringQueryBuilder mutateInstance(QueryStringQueryBuilder instance)
protected void doAssertLuceneQuery(QueryStringQueryBuilder queryBuilder,
Query query, SearchContext context) throws IOException {
assertThat(query, either(instanceOf(TermQuery.class))
.or(instanceOf(BooleanQuery.class)).or(instanceOf(DisjunctionMaxQuery.class))
.or(instanceOf(PhraseQuery.class)).or(instanceOf(BoostQuery.class))
.or(instanceOf(MultiPhrasePrefixQuery.class)).or(instanceOf(PrefixQuery.class)).or(instanceOf(SpanQuery.class))
.or(instanceOf(MatchNoDocsQuery.class)));
.or(instanceOf(BooleanQuery.class)).or(instanceOf(DisjunctionMaxQuery.class))
.or(instanceOf(BlendedTermQuery.class)).or(instanceOf(PhraseQuery.class))
.or(instanceOf(BoostQuery.class)).or(instanceOf(MultiPhrasePrefixQuery.class))
.or(instanceOf(PrefixQuery.class)).or(instanceOf(SpanQuery.class))
.or(instanceOf(MatchNoDocsQuery.class)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimczi @jtibshirani the query string query that gets translated to a Lucene BlendedTermQuery in the previously failing test is:

{
  "query_string" : {
    "query" : "sMPjDLuo ",
    "fields" : [
      "mapped_string^0.4345442",
      "mapped_string_alias^1.0"
    ],
    "type" : "cross_fields",
    "tie_breaker" : 0.5032719,
    "default_operator" : "or",
    "max_determinized_states" : 10000,
    "allow_leading_wildcard" : true,
    "enable_position_increments" : true,
    "fuzziness" : "1",
    "fuzzy_prefix_length" : 0,
    "fuzzy_max_expansions" : 50,
    "phrase_slop" : 3,
    "rewrite" : "scoring_boolean",
    "minimum_should_match" : "-25%",
    "quote_field_suffix" : "Qcu",
    "escape" : false,
    "auto_generate_synonyms_phrase_query" : true,
    "fuzzy_transpositions" : true,
    "boost" : 1.0,
    "_name" : "paAge15"
  }
}

It includes the newly introduced alias fields, so I assume the behaviour is correct, but can you re-check that adding this to the expected list of query classes is okay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second note, I also wouldn't be against removing these assertions altogether. In my opinion this makes the test more brittle and doesn't achieve much in terms of assertions, since the list of accepted classes is quite long already. Let me know if you also would approve if we remove this altogether.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to remove these assertions, the query_string query can build all sort of queries so I don't think we should track the full list here. This will also allow more flexibility in the random query generator.

}

// Tests fix for https://github.com/elastic/elasticsearch/issues/29403
Expand Down