def query_parser(): try: query = request.values.get("q", "", type=str) result = parse_query(query) return jsonify(result) except Exception: abort(400)
def query_parser(): if not current_app.config.get("FEATURE_FLAG_ENABLE_QUERY_PARSER_ENDPOINT", True): abort(404) try: query = request.values.get("q", "", type=str) result = parse_query(query) return jsonify(result) except Exception: abort(400)
def test_search_query_with_spires_syntax_in_literature_search(): query = u"a First Middle Last" expected_full_statement = inspire_query_parser.parse_query(query) expected_must_statement = expected_full_statement['nested']['query']['bool']['filter'] search = LiteratureSearch().query_from_iq(query) search_dict = search.to_dict() must_statement = search_dict['query']['bool']['must'] assert len(must_statement) == 1 must_statement = must_statement[0]['nested'] assert must_statement['path'] == 'authors' assert must_statement['query']['bool']['filter'][0] == expected_must_statement
def inspire_query(query_string, search): return Q(inspire_query_parser.parse_query(query_string))
def inspire_query(query_string, search): with RecursionLimit(current_app.config.get("SEARCH_MAX_RECURSION_LIMIT", 5000)): return Q(inspire_query_parser.parse_query(query_string))