X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/3f72ca4bcab2e0f6f0f6db89c7c2659d06858885..edb1eec46d0fd222f9b30e0e3d62e906c1c9059e:/test/python/api/search/test_icu_query_analyzer.py?ds=sidebyside diff --git a/test/python/api/search/test_icu_query_analyzer.py b/test/python/api/search/test_icu_query_analyzer.py index a88ca8b8..2ec3a7fe 100644 --- a/test/python/api/search/test_icu_query_analyzer.py +++ b/test/python/api/search/test_icu_query_analyzer.py @@ -138,6 +138,19 @@ async def test_category_words_only_at_beginning(conn): assert not query.nodes[2].starting +@pytest.mark.asyncio +async def test_freestanding_qualifier_words_become_category(conn): + ana = await tok.create_query_analyzer(conn) + + await add_word(conn, 1, 'foo', 'S', 'FOO', {'op': '-'}) + + query = await ana.analyze_query(make_phrase('foo')) + + assert query.num_token_slots() == 1 + assert len(query.nodes[0].starting) == 1 + assert query.nodes[0].starting[0].ttype == TokenType.NEAR_ITEM + + @pytest.mark.asyncio async def test_qualifier_words(conn): ana = await tok.create_query_analyzer(conn) @@ -148,9 +161,9 @@ async def test_qualifier_words(conn): query = await ana.analyze_query(make_phrase('foo BAR foo BAR foo')) assert query.num_token_slots() == 5 - assert set(t.ttype for t in query.nodes[0].starting) == {TokenType.NEAR_ITEM, TokenType.QUALIFIER} + assert set(t.ttype for t in query.nodes[0].starting) == {TokenType.QUALIFIER} assert set(t.ttype for t in query.nodes[2].starting) == {TokenType.QUALIFIER} - assert set(t.ttype for t in query.nodes[4].starting) == {TokenType.NEAR_ITEM, TokenType.QUALIFIER} + assert set(t.ttype for t in query.nodes[4].starting) == {TokenType.QUALIFIER} @pytest.mark.asyncio