private void assertUrlQuery(String field, Query query, boolean startAnchor, boolean endAnchor, boolean endAnchorIsDefault) {
        boolean startAnchorIsDefault = false; // Always

        // Set up
        SearchDefinition test = new SearchDefinition("test");
        Index urlField = new Index("urlfield");
        urlField.setUriIndex(true);
        test.addIndex(urlField);
        Index hostField = new Index("urlfield.hostname");
        hostField.setHostIndex(true);
        test.addIndex(hostField);

        Chain<Searcher> searchChain = new Chain<>(new MinimalQueryInserter());
        Execution.Context context = Execution.Context.createContextStub(new IndexFacts(new IndexModel(test)));
        Execution execution = new Execution(searchChain, context);
        execution.search(query);

        // Check parsing and serial forms
        if (endAnchor && startAnchor)
            assertEquals(field + ":\"^ google com $\"", query.getModel().getQueryTree().toString());
        else if (startAnchor)
            assertEquals(field + ":\"^ google com\"", query.getModel().getQueryTree().toString());
        else if (endAnchor)
            assertEquals(field + ":\"google com $\"", query.getModel().getQueryTree().toString());
        else
            assertEquals(field + ":\"google com\"", query.getModel().getQueryTree().toString());


        boolean hasAnnotations = startAnchor != startAnchorIsDefault || endAnchor != endAnchorIsDefault;
        StringBuilder expectedYql = new StringBuilder("select * from sources * where ");
        expectedYql.append(field).append(" contains ");
        if (hasAnnotations)
            expectedYql.append("({");
        if (startAnchor != startAnchorIsDefault)
            expectedYql.append("startAnchor: " + startAnchor);
        if (endAnchor != endAnchorIsDefault) {
            if (startAnchor != startAnchorIsDefault)
                expectedYql.append(", ");
            expectedYql.append("endAnchor: " + endAnchor);
        }
        if (hasAnnotations)
            expectedYql.append("}");
        expectedYql.append("uri(");
        if (query.properties().get("yql") != null)
            expectedYql.append("\"google.com\")"); // source string is preserved when parsing YQL
        else
            expectedYql.append("\"google com\")"); // but not with the simple syntax
        if (hasAnnotations)
            expectedYql.append(")");
        assertEquals(expectedYql.toString(), query.yqlRepresentation());

        assertTrue(query.getModel().getQueryTree().getRoot() instanceof PhraseItem);
        PhraseItem root = (PhraseItem)query.getModel().getQueryTree().getRoot();
        int expectedLength = 2;
        if (startAnchor)
            expectedLength++;
        if (endAnchor)
            expectedLength++;
        assertEquals(expectedLength, root.getNumWords());

        if (startAnchor)
            assertEquals(MarkerWordItem.createStartOfHost("urlfield.hostname"), root.getItem(0));
        if (endAnchor)
            assertEquals(MarkerWordItem.createEndOfHost("urlfield.hostname"), root.getItem(expectedLength-1));

        // Check YQL parser-serialization roundtrip
        Query reserialized = new Query();
        reserialized.properties().set("yql", query.yqlRepresentation());
        execution = new Execution(searchChain, context);
        execution.search(reserialized);
        assertEquals(query.yqlRepresentation(), reserialized.yqlRepresentation());
    }
Verifies that we can search for a backslash
container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java