def add_search_string(self: Any, search_string: str) -> Any:
     self.query["dis_max"]["queries"].append(
         query_utils.title_exact_match_query(fields=title_fields(
             [IndicesKey.CONCEPTS]),
                                             search_string=search_string))
     self.query["dis_max"]["queries"].append(
         query_utils.title_query(
             fields=title_fields([IndicesKey.CONCEPTS]),
             search_string=search_string,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.organization_and_keyword_query(search_string))
     self.query["dis_max"]["queries"].append(
         query_utils.description_query(
             fields=description_fields([IndicesKey.CONCEPTS]),
             search_string=search_string,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.simple_query_string(
             fields=fulltext_fields([IndicesKey.CONCEPTS]),
             search_string=search_string,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.query_string(
             fields=fulltext_fields([IndicesKey.CONCEPTS]),
             search_string=search_string,
         ))
 def add_search_string(self: Any, param: str) -> Any:
     self.query["dis_max"]["queries"].append(
         query_utils.title_exact_match_query(
             fields=title_fields(
                 [IndicesKey.EVENTS, IndicesKey.PUBLIC_SERVICES]),
             search_string=param,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.title_query(
             fields=title_fields(
                 [IndicesKey.EVENTS, IndicesKey.PUBLIC_SERVICES]),
             search_string=param,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.organization_and_keyword_query(param))
     self.query["dis_max"]["queries"].append(
         query_utils.description_query(
             fields=description_fields(
                 [IndicesKey.EVENTS, IndicesKey.PUBLIC_SERVICES]),
             search_string=param,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.simple_query_string(
             fields=fulltext_fields(
                 [IndicesKey.EVENTS, IndicesKey.PUBLIC_SERVICES]),
             search_string=param,
         ))
     self.query["dis_max"]["queries"].append(
         query_utils.query_string(
             fields=fulltext_fields(
                 [IndicesKey.EVENTS, IndicesKey.PUBLIC_SERVICES]),
             search_string=param,
         ))
def test_word_in_description_several_words():
    expected = {
        "bool": {
            "must": {
                "simple_query_string": {
                    "query": "åpne+data åpne+data*",
                    "fields":
                    ["description", "definition.text.*", "schema^0.5"],
                }
            },
            "should": [
                {
                    "match": {
                        "provenance.code": "NASJONAL"
                    }
                },
                {
                    "term": {
                        "nationalComponent": "true"
                    }
                },
                {
                    "bool": {
                        "must": [
                            {
                                "term": {
                                    "accessRights.code.keyword": "PUBLIC"
                                }
                            },
                            {
                                "term": {
                                    "distribution.openLicense": "true"
                                }
                            },
                        ]
                    }
                },
            ],
        }
    }
    result = description_query(
        fields=["description", "definition.text.*", "schema^0.5"],
        search_string="åpne data",
    )
    assert json.dumps(result) == json.dumps(expected)