NCIOCPL / glossary-api

API for Dictionary of Cancer Terms, Dictionary of Genetics Terms, and other Glossary documents.
0 stars 5 forks source link

Fix GetSuggestions_TestBeginsRequestSetup unit test failure #156

Closed blairlearn closed 2 years ago

blairlearn commented 2 years ago

Issue description

Following the update to Elasticsearch 7.9 and the NEST client, the GetSuggestions_TestBeginsRequestSetup test now fails.

The NEST client has changed its behavior.

In 5.6, MatchPhraseQuery {Field = "term_name._autocomplete", Query = "lung" } resulted in the query fragment

    {
        "match": {
            "term_name._autocomplete": {
                "query": "lung",
                "type": "phrase"
            }
        }
    }

Beginning with 6, the same middle tier code now results in the fragment

    {
        "match_phrase": {
            "term_name._autocomplete": {
                "query": "lung"
            }
        }
    }

The newer behavior is what the query for "Contains" autosuggest is supposed to look like.

ESTIMATE TBD

Steps to reproduce the issue

  1. Run the unit tests

What's the expected result?

What's the actual result?

Additional details / screenshot

Related Tickets

blairlearn commented 2 years ago

The type property/argument/option doesn't appear in the ES5 documentation, but according to the 2.x documentation "...match_phrase is only a type of a match query...."

It appears the type parameter was deprecated in version 5, but not removed from NEST client until version 6.

Also important, the integration tests don't show any change in the search's behavior.

The fix then seems to be to update the expected query to use match_phrase.