Example usage for java.util Locale FRENCH

List of usage examples for java.util Locale FRENCH

Introduction

In this page you can find the example usage for java.util Locale FRENCH.

Prototype

Locale FRENCH

To view the source code for java.util Locale FRENCH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.openmrs.api.ConceptServiceTest.java

/**
 * @verifies get drugs linked to concepts with names that match the phrase and locale
 * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean)
 *//*w w  w .j av a 2  s.  c  om*/
@Test
public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhraseAndLocale() throws Exception {
    executeDataSet("org/openmrs/api/include/ConceptServiceTest-drugSearch.xml");
    final String searchPhrase = "some";
    List<Drug> drugs = conceptService.getDrugs(searchPhrase, Locale.FRENCH, true, false);
    assertEquals(0, drugs.size());

    drugs = conceptService.getDrugs(searchPhrase, Locale.CANADA_FRENCH, true, false);
    assertEquals(1, drugs.size());
    assertEquals(3, drugs.get(0).getDrugId().intValue());
}

From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java

/**
 * @throws Exception//  w ww.j  ava2 s . c  o m
 */
public void testSort() throws Exception {
    Collator collator = Collator.getInstance(I18NUtil.getLocale());

    luceneFTS.pause();
    buildBaseIndex();
    runBaseTests();

    ADMLuceneSearcherImpl searcher = buildSearcher();

    SearchParameters sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery("PATH:\"//.\"");
    sp.addSort("ID", true);
    ResultSet results = searcher.query(sp);

    String current = null;
    for (ResultSetRow row : results) {
        String id = row.getNodeRef().getId();

        if (current != null) {
            if (collator.compare(current, id) > 0) {
                fail();
            }
        }
        current = id;
    }
    results.close();

    SearchParameters sp2 = new SearchParameters();
    sp2.addStore(rootNodeRef.getStoreRef());
    sp2.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp2.setQuery("PATH:\"//.\"");
    sp2.addSort("ID", false);
    results = searcher.query(sp2);

    current = null;
    for (ResultSetRow row : results) {
        String id = row.getNodeRef().getId();
        if (current != null) {
            if (collator.compare(current, id) < 0) {
                fail();
            }
        }
        current = id;
    }
    results.close();

    luceneFTS.resume();

    SearchParameters sp3 = new SearchParameters();
    sp3.addStore(rootNodeRef.getStoreRef());
    sp3.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp3.setQuery("PATH:\"//.\"");
    sp3.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_ASCENDING);
    results = searcher.query(sp3);

    int count = 0;
    for (ResultSetRow row : results) {
        assertEquals(documentOrder[count++], row.getNodeRef());
    }
    results.close();

    SearchParameters sp4 = new SearchParameters();
    sp4.addStore(rootNodeRef.getStoreRef());
    sp4.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp4.setQuery("PATH:\"//.\"");
    sp4.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_DESCENDING);
    results = searcher.query(sp4);

    count = 1;
    for (ResultSetRow row : results) {
        assertEquals(documentOrder[documentOrder.length - (count++)], row.getNodeRef());
    }
    results.close();

    SearchParameters sp5 = new SearchParameters();
    sp5.addStore(rootNodeRef.getStoreRef());
    sp5.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp5.setQuery("PATH:\"//.\"");
    sp5.addSort(SearchParameters.SORT_IN_SCORE_ORDER_ASCENDING);
    results = searcher.query(sp5);

    float score = 0;
    for (ResultSetRow row : results) {
        assertTrue(score <= row.getScore());
        score = row.getScore();
    }
    results.close();

    SearchParameters sp6 = new SearchParameters();
    sp6.addStore(rootNodeRef.getStoreRef());
    sp6.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp6.setQuery("PATH:\"//.\"");
    sp6.addSort(SearchParameters.SORT_IN_SCORE_ORDER_DESCENDING);
    results = searcher.query(sp6);

    score = 1.0f;
    for (ResultSetRow row : results) {
        assertTrue(score >= row.getScore());
        score = row.getScore();
    }
    results.close();

    // sort by created date

    SearchParameters sp7 = new SearchParameters();
    sp7.addStore(rootNodeRef.getStoreRef());
    sp7.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp7.setQuery("PATH:\"//.\"");
    sp7.addSort("@" + createdDate.getPrefixedQName(namespacePrefixResolver), true);
    results = searcher.query(sp7);

    Date date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), createdDate));
        // System.out.println(currentBun);
        if (date != null) {
            assertTrue(date.compareTo(currentBun) <= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp8 = new SearchParameters();
    sp8.addStore(rootNodeRef.getStoreRef());
    sp8.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp8.setQuery("PATH:\"//.\"");
    sp8.addSort("@" + createdDate, false);
    results = searcher.query(sp8);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), createdDate));
        // System.out.println(currentBun);
        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) >= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp_7 = new SearchParameters();
    sp_7.addStore(rootNodeRef.getStoreRef());
    sp_7.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp_7.setQuery("PATH:\"//.\"");
    sp_7.addSort("@" + ContentModel.PROP_MODIFIED, true);
    results = searcher.query(sp_7);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
        if (currentBun != null) {
            Calendar c = new GregorianCalendar();
            c.setTime(currentBun);
            c.set(Calendar.MILLISECOND, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.HOUR_OF_DAY, 0);
            currentBun = c.getTime();
        }
        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) <= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp_8 = new SearchParameters();
    sp_8.addStore(rootNodeRef.getStoreRef());
    sp_8.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp_8.setQuery("PATH:\"//.\"");
    sp_8.addSort("@" + ContentModel.PROP_MODIFIED, false);
    results = searcher.query(sp_8);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
        // System.out.println(currentBun);
        if (currentBun != null) {
            Calendar c = new GregorianCalendar();
            c.setTime(currentBun);
            c.set(Calendar.MILLISECOND, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.HOUR_OF_DAY, 0);
            currentBun = c.getTime();
        }

        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) >= 0);
        }
        date = currentBun;
    }
    results.close();

    // sort by double

    SearchParameters sp9 = new SearchParameters();
    sp9.addStore(rootNodeRef.getStoreRef());
    sp9.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp9.setQuery("PATH:\"//.\"");
    sp9.addSort("@" + orderDouble, true);
    results = searcher.query(sp9);

    Double d = null;
    for (ResultSetRow row : results) {
        Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class,
                nodeService.getProperty(row.getNodeRef(), orderDouble));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (d != null) {
            assertTrue(d.compareTo(currentBun) <= 0);
        }
        d = currentBun;
    }
    results.close();

    SearchParameters sp10 = new SearchParameters();
    sp10.addStore(rootNodeRef.getStoreRef());
    sp10.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp10.setQuery("PATH:\"//.\"");
    sp10.addSort("@" + orderDouble, false);
    results = searcher.query(sp10);

    d = null;
    for (ResultSetRow row : results) {
        Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class,
                nodeService.getProperty(row.getNodeRef(), orderDouble));
        // System.out.println(currentBun);
        if ((d != null) && (currentBun != null)) {
            assertTrue(d.compareTo(currentBun) >= 0);
        }
        d = currentBun;
    }
    results.close();

    // sort by float

    SearchParameters sp11 = new SearchParameters();
    sp11.addStore(rootNodeRef.getStoreRef());
    sp11.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp11.setQuery("PATH:\"//.\"");
    sp11.addSort("@" + orderFloat, true);
    results = searcher.query(sp11);

    Float f = null;
    for (ResultSetRow row : results) {
        Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class,
                nodeService.getProperty(row.getNodeRef(), orderFloat));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (f != null) {
            assertTrue(f.compareTo(currentBun) <= 0);
        }
        f = currentBun;
    }
    results.close();

    SearchParameters sp12 = new SearchParameters();
    sp12.addStore(rootNodeRef.getStoreRef());
    sp12.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp12.setQuery("PATH:\"//.\"");
    sp12.addSort("@" + orderFloat, false);
    results = searcher.query(sp12);

    f = null;
    for (ResultSetRow row : results) {
        Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class,
                nodeService.getProperty(row.getNodeRef(), orderFloat));
        // System.out.println(currentBun);
        if ((f != null) && (currentBun != null)) {
            assertTrue(f.compareTo(currentBun) >= 0);
        }
        f = currentBun;
    }
    results.close();

    // sort by long

    SearchParameters sp13 = new SearchParameters();
    sp13.addStore(rootNodeRef.getStoreRef());
    sp13.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp13.setQuery("PATH:\"//.\"");
    sp13.addSort("@" + orderLong, true);
    results = searcher.query(sp13);

    Long l = null;
    for (ResultSetRow row : results) {
        Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class,
                nodeService.getProperty(row.getNodeRef(), orderLong));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (l != null) {
            assertTrue(l.compareTo(currentBun) <= 0);
        }
        l = currentBun;
    }
    results.close();

    SearchParameters sp14 = new SearchParameters();
    sp14.addStore(rootNodeRef.getStoreRef());
    sp14.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp14.setQuery("PATH:\"//.\"");
    sp14.addSort("@" + orderLong, false);
    results = searcher.query(sp14);

    l = null;
    for (ResultSetRow row : results) {
        Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class,
                nodeService.getProperty(row.getNodeRef(), orderLong));
        // System.out.println(currentBun);
        if ((l != null) && (currentBun != null)) {
            assertTrue(l.compareTo(currentBun) >= 0);
        }
        l = currentBun;
    }
    results.close();

    // sort by int

    SearchParameters sp15 = new SearchParameters();
    sp15.addStore(rootNodeRef.getStoreRef());
    sp15.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp15.setQuery("PATH:\"//.\"");
    sp15.addSort("@" + orderInt, true);
    results = searcher.query(sp15);

    Integer i = null;
    for (ResultSetRow row : results) {
        Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class,
                nodeService.getProperty(row.getNodeRef(), orderInt));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (i != null) {
            assertTrue(i.compareTo(currentBun) <= 0);
        }
        i = currentBun;
    }
    results.close();

    SearchParameters sp16 = new SearchParameters();
    sp16.addStore(rootNodeRef.getStoreRef());
    sp16.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp16.setQuery("PATH:\"//.\"");
    sp16.addSort("@" + orderInt, false);
    results = searcher.query(sp16);

    i = null;
    for (ResultSetRow row : results) {
        Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class,
                nodeService.getProperty(row.getNodeRef(), orderInt));
        // System.out.println(currentBun);
        if ((i != null) && (currentBun != null)) {
            assertTrue(i.compareTo(currentBun) >= 0);
        }
        i = currentBun;
    }
    results.close();

    // sort by text

    SearchParameters sp17 = new SearchParameters();
    sp17.addStore(rootNodeRef.getStoreRef());
    sp17.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp17.setQuery("PATH:\"//.\"");
    sp17.addSort("@" + orderText, true);
    results = searcher.query(sp17);

    String text = null;
    for (ResultSetRow row : results) {
        String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class,
                nodeService.getProperty(row.getNodeRef(), orderText));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if ((text != null) && (currentBun != null)) {
            assertTrue(collator.compare(text, currentBun) <= 0);
        }
        text = currentBun;
    }
    results.close();

    SearchParameters sp18 = new SearchParameters();
    sp18.addStore(rootNodeRef.getStoreRef());
    sp18.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp18.setQuery("PATH:\"//.\"");
    sp18.addSort("@" + orderText, false);
    results = searcher.query(sp18);

    text = null;
    for (ResultSetRow row : results) {
        String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class,
                nodeService.getProperty(row.getNodeRef(), orderText));
        // System.out.println(currentBun);
        if ((text != null) && (currentBun != null)) {
            assertTrue(collator.compare(text, currentBun) >= 0);
        }
        text = currentBun;
    }
    results.close();

    // sort by content size

    // sort by ML text

    // Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH, Locale.CHINESE };
    Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH };
    for (Locale testLocale : testLocales) {
        Collator localisedCollator = Collator.getInstance(testLocale);

        SearchParameters sp19 = new SearchParameters();
        sp19.addStore(rootNodeRef.getStoreRef());
        sp19.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp19.setQuery("PATH:\"//.\"");
        sp19.addSort("@" + orderMLText, true);
        sp19.addLocale(testLocale);
        results = searcher.query(sp19);

        text = null;
        for (ResultSetRow row : results) {
            MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class,
                    nodeService.getProperty(row.getNodeRef(), orderMLText));
            if (mltext != null) {
                String currentBun = mltext.getValue(testLocale);
                // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ "
                // "+currentBun);
                if ((text != null) && (currentBun != null)) {
                    assertTrue(localisedCollator.compare(text, currentBun) <= 0);
                }
                text = currentBun;
            }
        }
        results.close();

        SearchParameters sp20 = new SearchParameters();
        sp20.addStore(rootNodeRef.getStoreRef());
        sp20.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp20.setQuery("PATH:\"//.\"");
        sp20.addSort("@" + orderMLText, false);
        sp20.addLocale(testLocale);
        results = searcher.query(sp20);

        text = null;
        for (ResultSetRow row : results) {
            MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class,
                    nodeService.getProperty(row.getNodeRef(), orderMLText));
            if (mltext != null) {
                String currentBun = mltext.getValue(testLocale);
                if ((text != null) && (currentBun != null)) {
                    assertTrue(localisedCollator.compare(text, currentBun) >= 0);
                }
                text = currentBun;
            }
        }
        results.close();

    }

    luceneFTS.resume();

    SearchParameters spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("cabbage", false);
    results = searcher.query(spN);
    results.close();

    // test sort on unkown properties ALF-4193

    spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("PARENT", false);
    results = searcher.query(spN);
    results.close();

    spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("@PARENT:PARENT", false);
    results = searcher.query(spN);
    results.close();

    luceneFTS.resume();

    // sort by content size

    SearchParameters sp20 = new SearchParameters();
    sp20.addStore(rootNodeRef.getStoreRef());
    sp20.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp20.setQuery("PATH:\"//.\"");
    sp20.addSort("@" + ContentModel.PROP_CONTENT + ".size", false);
    results = searcher.query(sp20);

    Long size = null;
    for (ResultSetRow row : results) {
        ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT));
        // System.out.println(currentBun);
        if ((size != null) && (currentBun != null)) {
            assertTrue(size.compareTo(currentBun.getSize()) >= 0);
        }
        if (currentBun != null) {
            size = currentBun.getSize();
        }
    }
    results.close();

    // sort by content mimetype

    SearchParameters sp21 = new SearchParameters();
    sp21.addStore(rootNodeRef.getStoreRef());
    sp21.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp21.setQuery("PATH:\"//.\"");
    sp21.addSort("@" + ContentModel.PROP_CONTENT + ".mimetype", false);
    results = searcher.query(sp21);

    String mimetype = null;
    for (ResultSetRow row : results) {
        ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT));
        // System.out.println(currentBun);
        if ((mimetype != null) && (currentBun != null)) {
            assertTrue(mimetype.compareTo(currentBun.getMimetype()) >= 0);
        }
        if (currentBun != null) {
            mimetype = currentBun.getMimetype();
        }
    }
    results.close();

}

From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java

private void runBaseTests() throws LuceneIndexException, IOException {
    ADMLuceneSearcherImpl searcher = buildSearcher();
    ResultSet results;/*  ww  w  .java 2 s .  c o m*/
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/.\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:three\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:four\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:eight-0\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:five\"", null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:one\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:two\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:one\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:two\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:six\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:seven\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-1\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-2\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-2\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-1\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-0\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-0\"",
            null);
    assertEquals(0, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:nine\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:ten\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:eleven\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:twelve\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen/namespace:fourteen\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen/namespace:common\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:common\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*\"", null);
    assertEquals(5, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATHWITHREPEATS:\"/namespace:*/namespace:*\"", null);
    assertEquals(8, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:*\"", null);
    assertEquals(6, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:five\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATHWITHREPEATS:\"/namespace:*/namespace:*/namespace:*\"", null);
    assertEquals(9, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:*/namespace:*/namespace:*\"", null);
    assertEquals(6, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:*\"", null);
    assertEquals(4, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:*/namespace:five/namespace:*\"", null);
    assertEquals(5, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "PATH:\"/namespace:one/namespace:*/namespace:nine\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*\"", null);
    assertEquals(5, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/*/*\"", null);
    assertEquals(8, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*\"", null);
    assertEquals(6, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/namespace:five\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/*/*/*\"", null);
    assertEquals(9, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*/*\"", null);
    assertEquals(6, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/*\"", null);
    assertEquals(4, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/namespace:five/*\"", null);
    assertEquals(5, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/*/namespace:nine\"",
            null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//.\"", null);
    assertEquals(28, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//.\"", null);
    assertEquals(16, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*\"", null);
    assertEquals(15, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*\"", null);
    assertEquals(27, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*/.\"", null);
    assertEquals(15, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*/.\"", null);
    assertEquals(27, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*/./.\"", null);
    assertEquals(15, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*/./.\"", null);
    assertEquals(27, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//./*\"", null);
    assertEquals(27, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//./*\"", null);
    assertEquals(15, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//././*/././.\"", null);
    assertEquals(15, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//././*/././.\"", null);
    assertEquals(27, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//common\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//common\"", null);
    assertEquals(7, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//common\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one//common\"", null);
    assertEquals(5, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one/five//*\"", null);
    assertEquals(7, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one/five//*\"", null);
    assertEquals(10, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one/five//.\"", null);
    assertEquals(8, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one/five//.\"", null);
    assertEquals(11, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//five/nine\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen/.\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen//.\"", null);
    assertEquals(1, results.length());
    results.close();
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen//.//.\"",
            null);
    assertEquals(1, results.length());
    results.close();

    // QNames

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "QNAME:\"nine\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PRIMARYASSOCTYPEQNAME:\"lucene-test:assoc\"",
            null);
    assertEquals(11, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASSOCTYPEQNAME:\"lucene-test:assoc\"", null);
    assertEquals(11, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PRIMARYASSOCTYPEQNAME:\"sys:children\"",
            null);
    assertEquals(4, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASSOCTYPEQNAME:\"sys:children\"", null);
    assertEquals(5, results.length());
    results.close();

    // Type search tests

    QName qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"1\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":1", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"01\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":01", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + escapeQName(qname) + ":\"001\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@lucene-test\\:int\\-ista:\"0001\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 2]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO 2]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 1}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO 1}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO A}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 2}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{1 TO 2}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{1 TO A}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"2\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"02\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"002\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"0002\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 2]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO 2]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 2}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO 2}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO A}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 3}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{2 TO 3}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "long-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{2 TO A}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"3.4\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 4]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3 TO 4]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 3.4]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO 3.4]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 3.4}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO 3.4]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"3.40\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"03.4\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "float-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"03.40\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"5.6\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"05.6\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"5.60\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"05.60\"", null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 5.7]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[5.5 TO 5.7]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[5.5 TO A]",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 5.6}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.5 TO 5.6}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.5 TO A}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 5.7}",
            null);
    assertEquals(1, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.6 TO 5.7}",
            null);
    assertEquals(0, results.length());
    results.close();

    qname = QName.createQName(TEST_NAMESPACE, "double-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.6 TO A}",
            null);
    assertEquals(0, results.length());
    results.close();

    // Dates

    PropertyDefinition propertyDef = dictionaryService
            .getProperty(QName.createQName(TEST_NAMESPACE, "datetime-ista"));
    DataTypeDefinition dataType = propertyDef.getDataType();
    String analyserClassName = propertyDef.resolveAnalyserClassName();
    boolean usesDateTimeAnalyser = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName());

    Date date = new Date();
    for (SimpleDateFormatAndResolution df : CachingDateFormat.getLenientFormatters()) {
        if (!usesDateTimeAnalyser && (df.getResolution() < Calendar.DAY_OF_MONTH)) {
            continue;
        }
        System.out.println("Date format: " + df.getSimpleDateFormat());

        //            if(usesDateTimeAnalyser && (df.getSimpleDateFormat().format(date).length() < 22))
        //            {
        //                continue;
        //            }

        //            String sDate = df.getSimpleDateFormat().format(date);
        //            results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "DATE-ista")) + ":\"" + sDate + "\"", null);
        //            assertEquals(1, results.length());
        //            results.close();
        //
        //            results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"", null);
        //            assertEquals(usesDateTimeAnalyser ? 0 : 1, results.length());
        //            results.close();

        String sDate = df.getSimpleDateFormat().format(testDate);

        if (sDate.length() >= 9) {
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                    "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":\"" + sDate + "\"",
                    null);
            assertEquals(1, results.length());
            results.close();
        }

        results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"",
                null);
        assertEquals(1, results.length());
        results.close();

        // short and long field ranges

        // note: expected 2 results = n14 (cm:content) and n15 (cm:thumbnail)

        sDate = df.getSimpleDateFormat().format(date);
        results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:CrEaTeD:[MIN TO " + sDate + "]",
                null);
        assertEquals(2, results.length());
        assertTrue("n14 not in results",
                (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14)));
        assertTrue("n15 not in results",
                (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15)));
        results.close();

        results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:created:[MIN TO NOW]", null);
        assertEquals(2, results.length());
        assertTrue("n14 not in results",
                (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14)));
        assertTrue("n15 not in results",
                (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15)));
        results.close();

        results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:created:[MIN TO NOW]", null);
        assertEquals(2, results.length());
        assertTrue("n14 not in results",
                (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14)));
        assertTrue("n15 not in results",
                (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15)));
        results.close();

        sDate = df.getSimpleDateFormat().format(date);
        results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                "\\@" + escapeQName(ContentModel.PROP_CREATED) + ":[MIN TO " + sDate + "]", null);
        assertEquals(2, results.length());
        assertTrue("n14 not in results",
                (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14)));
        assertTrue("n15 not in results",
                (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15)));
        results.close();

        // Date ranges
        // Test date collapses but date time does not

        if (sDate.length() >= 9) {
            sDate = df.getSimpleDateFormat().format(testDate);
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                    "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[" + sDate + " TO "
                            + sDate + "]",
                    null);
            assertEquals(1, results.length());
            results.close();

            sDate = df.getSimpleDateFormat().format(testDate);
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
                    + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[MIN  TO " + sDate + "]",
                    null);
            assertEquals(1, results.length());
            results.close();

            sDate = df.getSimpleDateFormat().format(testDate);
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
                    + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[" + sDate + " TO MAX]",
                    null);
            assertEquals(1, results.length());
            results.close();
        }

        if (!usesDateTimeAnalyser) {
            // with date time the result is indeterminate
            sDate = CachingDateFormat.getDateFormat().format(testDate);
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                    "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate
                            + " TO " + sDate + "]",
                    null);
            assertEquals(1, results.length());
            results.close();
        }

        sDate = CachingDateFormat.getDateFormat().format(testDate);
        results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
                + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[MIN TO " + sDate + "]",
                null);
        assertEquals(1, results.length());
        results.close();

        sDate = CachingDateFormat.getDateFormat().format(testDate);
        System.out.println("SD = " + sDate);
        System.out.println("D = " + date);

        if (!usesDateTimeAnalyser) {
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
                    + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"",
                    null);
            //TODO: Fix date time resolution - uses 000 MS
            assertEquals(1, results.length());
            results.close();
        }

        if (!usesDateTimeAnalyser) {
            results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                    "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate
                            + " TO MAX]",
                    null);
            assertEquals(1, results.length());
            results.close();
        }

        if (usesDateTimeAnalyser) {
            sDate = df.getSimpleDateFormat().format(testDate);
            System.out.println("Test Date = " + testDate);
            System.out.println("Formatted = " + sDate);

            for (long i : new long[] { 333, 20000, 20 * 60 * 1000, 8 * 60 * 60 * 1000, 10 * 24 * 60 * 60 * 1000,
                    4 * 30 * 24 * 60 * 60 * 1000, 10 * 12 * 30 * 24 * 60 * 60 * 1000 }) {
                System.out.println("I = " + i);

                String startDate = df.getSimpleDateFormat().format(new Date(testDate.getTime() - i));
                System.out.println("\tStart = " + startDate);

                String endDate = df.getSimpleDateFormat().format(new Date(testDate.getTime() + i));
                System.out.println("\tEnd = " + endDate);

                boolean equalsStart = startDate.equals(sDate);
                boolean equalsEnd = endDate.equals(sDate);
                boolean equalsStartOrEnd = equalsStart || equalsEnd;

                results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                        "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":["
                                + startDate + " TO " + endDate + "]",
                        null);
                assertEquals(1, results.length());
                results.close();

                results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                        "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate
                                + " TO " + endDate + "]",
                        null);
                assertEquals(1, results.length());
                results.close();

                results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                        "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":["
                                + startDate + " TO " + sDate + "]",
                        null);
                assertEquals(1, results.length());
                results.close();

                results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                        "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{" + sDate
                                + " TO " + endDate + "}",
                        null);
                assertEquals(0, results.length());
                results.close();

                results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
                        "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{"
                                + startDate + " TO " + sDate + "}",
                        null);
                assertEquals(0, results.length());
                results.close();
            }
        }
    }

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "boolean-ista")) + ":\"true\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "qname-ista")) + ":\"{wibble}wobble\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "category-ista")) + ":\""
                    + DefaultTypeConverter.INSTANCE.convert(String.class,
                            new NodeRef(rootNodeRef.getStoreRef(), "CategoryId"))
                    + "\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "noderef-ista")) + ":\"" + n1 + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "path-ista")) + ":\""
                    + nodeService.getPath(n3) + "\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    // d:any

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"100\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"anyValueAsString\"",
            null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"nintc\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista")));
    results.close();

    // proximity searches

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~0", null);
    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~1", null);
    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~2", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~3", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Alfresco Tutorial\"",
            null);

    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Tutorial Alfresco\"",
            null);

    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Tutorial Alfresco\"~0",
            null);

    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Tutorial Alfresco\"~1",
            null);

    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Tutorial Alfresco\"~2",
            null);

    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
                    + ":\"Tutorial Alfresco\"~3",
            null);

    assertEquals(1, results.length());
    results.close();

    // multi ml text

    QName multimlQName = QName.createQName(TEST_NAMESPACE, "mltext-many-ista");

    SearchParameters sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":");
    sp.addLocale(new Locale("ru"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":lemur");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":chou");
    sp.addLocale(new Locale("fr"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabbage");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabba*");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":ca*ge");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":*bage");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabage~");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":*b?ag?");
    sp.addLocale(new Locale("en"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cho*");
    sp.setMlAnalaysisMode(MLAnalysisMode.LOCALE_AND_ALL_CONTAINED_LOCALES);
    sp.addLocale(new Locale("fr"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // multivalued content in type d:any
    // This should not be indexed as we can not know what to do with content here.

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(
            QName.createQName(TEST_NAMESPACE, "content-many-ista").toString()) + ":multicontent");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    // locale

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":\"en_GB_\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":en_GB_", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":en_*", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":*_GB_*", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":*_gb_*", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    // Period

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "period-ista")) + ":\"period|12\"", null);
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista")));
    results.close();

    // Type

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testType.toString() + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TYPE:\"" + testType.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTTYPE:\"" + testType.toString() + "\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "EXACTTYPE:\"" + testType.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testSuperType.toString() + "\"",
            null);
    assertEquals(13, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TYPE:\"" + testSuperType.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(13, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TYPE:\"" + ContentModel.TYPE_CONTENT.toString() + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"cm:content\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"cm:CONTENT\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"CM:CONTENT\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"CONTENT\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"content\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TYPE:\"" + ContentModel.TYPE_THUMBNAIL.toString() + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TYPE:\"" + ContentModel.TYPE_THUMBNAIL.toString() + "\" TYPE:\""
                    + ContentModel.TYPE_CONTENT.toString() + "\"",
            null);
    assertEquals(2, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "EXACTTYPE:\"" + testSuperType.toString() + "\"", null);
    assertEquals(12, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "EXACTTYPE:\"" + testSuperType.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(12, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASPECT:\"" + testAspect.toString() + "\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "ASPECT:\"" + testAspect.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "EXACTASPECT:\"" + testAspect.toString() + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "EXACTASPECT:\"" + testAspect.toPrefixString(namespacePrefixResolver) + "\"", null);
    assertEquals(1, results.length());
    results.close();

    // Test for AR-384

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TEXT:fox AND TYPE:\"" + ContentModel.PROP_CONTENT.toString() + "\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fox cm\\:name:fox", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TEXT:fo AND TYPE:\"" + ContentModel.PROP_CONTENT.toString() + "\"", null);
    assertEquals(0, results.length());
    results.close();

    // Test stop words are equivalent

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"the\"", null);
    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"and\"", null);
    assertEquals(0, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"over the lazy\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"over a lazy\"", null);
    assertEquals(1, results.length());
    results.close();

    // Test wildcards in text

    //ALF-2389
    //results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))+":*en*", null);
    //assertEquals(0, results.length());
    //results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
            + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*a*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
            + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*A*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))
                    + ":\"*a*\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))
                    + ":\"*A\"*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
            + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*s*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
            + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*S*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))
                    + ":\"*s*\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))
                    + ":\"*S\"*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*A*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*a*\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*A*\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*a*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*Z*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*z*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*Z*\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*z*\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:laz*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:laz~", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:la?y", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:?a?y", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*azy", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*az*", null);
    assertEquals(1, results.length());
    results.close();

    // Accents

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "TEXT:\"\u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"aeidnouy\"", null);
    assertEquals(1, results.length());
    results.close();

    // FTS test

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"fox\"", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":\"fox\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString())
                    + ".mimetype:\"text/plain\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString())
                    + ".locale:\"en_GB\"",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@"
            + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".locale:en_*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString())
                    + ".locale:e*_GB",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString())
                    + ".size:\"298\"",
            null);
    assertEquals(1, results.length());
    results.close();

    QName queryQName = QName.createQName("alf:test1", namespacePrefixResolver);
    results = searcher.query(rootNodeRef.getStoreRef(), queryQName, null);
    assertEquals(1, results.length());
    results.close();

    // Configuration of TEXT

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString())
            + ":\"fox\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"fox\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"fox\"");
    sp.addTextAttribute("@" + ContentModel.PROP_NAME.toString());
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp.addTextAttribute("@" + ContentModel.PROP_CONTENT.toString());
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"cabbage\"");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"cab*\"");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*bage\"");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*ba*\"");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    // term

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:cabbage");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:*cab*");
    sp.addTextAttribute("@" + orderText.toString());
    sp.addLocale(Locale.ENGLISH);
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:*bage");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:*ba*");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:dabbage~0.8");
    sp.addTextAttribute("@" + orderText.toString());
    results = searcher.query(sp);
    assertEquals(13, results.length());
    results.close();

    // Wild cards in TEXT phrase

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfresc?\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfres??\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfre???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfr????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alf?????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"al??????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"a???????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"a??re???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"?lfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"??fresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"???resco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"???res?o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"????e?co\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"????e?c?\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"???????o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"???re???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfresc*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfres*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfre*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfr*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alf*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"al*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"a*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"a****\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*lfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*fresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*resco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*esco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*sco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*co\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"****lf**sc***\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*??*lf**sc***\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alfresc*tutorial\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"alf* tut*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("TEXT:\"*co *al\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // Wild cards in ML phrases

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfresc?\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfres??\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfre???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfr????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alf?????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"al??????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"a???????\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"a??re???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"?lfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"??fresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"???resco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"???res?o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"????e?co\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"????e?c?\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"???????o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"???re???\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfresc*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfres*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfre*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alfr*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"alf*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"al*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"a*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"a****\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*lfresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*fresco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*resco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*esco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*sco\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*co\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*o\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"****lf**sc***\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*??*lf**sc***\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"Alfresc*tutorial\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"Alf* tut*\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString())
            + ":\"*co *al\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // ALL and its configuration

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ALL:\"fox\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ALL:\"fox\"");
    sp.addAllAttribute("@" + ContentModel.PROP_NAME.toString());
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp.addAllAttribute("@" + ContentModel.PROP_CONTENT.toString());
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ALL:\"5.6\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // Search by data type

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("d\\:double:\"5.6\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("d\\:content:\"fox\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // locale serach in en_US for en_UK

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("d\\:content:\"fox\"");
    sp.addLocale(Locale.US);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // Direct ML tests

    QName mlQName = QName.createQName(TEST_NAMESPACE, "ml");

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY);
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":and");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY);
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":\"and\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY);
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    sp.addLocale(Locale.UK);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    sp.setMlAnalaysisMode(MLAnalysisMode.LOCALE_AND_ALL_CONTAINING_LOCALES);
    sp.addLocale(Locale.UK);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    sp.addLocale(Locale.ENGLISH);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banane");
    sp.addLocale(Locale.FRENCH);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":");
    sp.addLocale(Locale.CHINESE);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banaan");
    sp.addLocale(new Locale("nl"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banane");
    sp.addLocale(Locale.GERMAN);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":");
    sp.addLocale(new Locale("el"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    sp.addLocale(Locale.ITALIAN);
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":?");
    sp.addLocale(new Locale("ja"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":");
    sp.addLocale(new Locale("ko"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana");
    sp.addLocale(new Locale("pt"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":");
    sp.addLocale(new Locale("ru"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":pltano");
    sp.addLocale(new Locale("es"));
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    // Test ISNULL/ISUNSET/ISNOTNULL

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\"");
    results = searcher.query(sp);
    // assertEquals(62, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\"");
    results = searcher.query(sp);
    // assertEquals(61, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(1, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\"");
    results = searcher.query(sp);
    // assertEquals(62, results.length());
    results.close();

    sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage("lucene");
    sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\"");
    results = searcher.query(sp);
    assertEquals(0, results.length());
    results.close();

    // Test non field queries

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fox", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fo*", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:f*x", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*ox", null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":fox",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":fo*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":f*x",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":*ox",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion
            .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":fox",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion
            .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":fo*",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion
            .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":f*x",
            null);
    assertEquals(1, results.length());
    results.close();

    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion
            .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":*ox",
            null);
    assertEquals(1, results.length());
    results.close();

    // Parameters

    queryQName = QName.createQName("alf:test2", namespacePrefixResolver);
    results = searcher.query(rootNodeRef.getStoreRef(), queryQName, null);
    assertEquals(1, results.length());
    results.close();

    queryQName = QName.createQName("alf:test2", namespacePrefixResolver);
    QueryParameter qp = new QueryParameter(QName.createQName("alf:banana", namespacePrefixResolver), "woof");
    results = searcher.query(rootNodeRef.getStoreRef(), queryQName, new QueryParameter[] { qp });
    assertEquals(0, results.length());
    results.close();

    queryQName = QName.createQName("alf:test3", namespacePrefixResolver);
    qp = new QueryParameter(QName.createQName("alf:banana", namespacePrefixResolver), "/one/five//*");
    results = searcher.query(rootNodeRef.getStoreRef(), queryQName, new QueryParameter[] { qp });
    assertEquals(7, results.length());
    results.close();

    // TODO: should not have a null property type definition
    QueryParameterDefImpl paramDef = new QueryParameterDefImpl(
            QName.createQName("alf:lemur", namespacePrefixResolver), (DataTypeDefinition) null, true, "fox");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"${alf:lemur}\"",
            new QueryParameterDefinition[] { paramDef });
    assertEquals(1, results.length());
    results.close();

    paramDef = new QueryParameterDefImpl(QName.createQName("alf:intvalue", namespacePrefixResolver),
            (DataTypeDefinition) null, true, "1");
    qname = QName.createQName(TEST_NAMESPACE, "int-ista");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
            "\\@" + escapeQName(qname) + ":\"${alf:intvalue}\"", new QueryParameterDefinition[] { paramDef });
    assertEquals(1, results.length());
    assertNotNull(results.getRow(0).getValue(qname));
    results.close();

    // Open ended ranges

    qname = QName.createQName("{namespace}property-1");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[v TO w]",
            null);
    assertEquals(2, results.length());
    results.close();

    qname = QName.createQName("{namespace}property-1");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[v TO \uFFFF]",
            null);
    assertEquals(2, results.length());
    results.close();

    qname = QName.createQName("{namespace}property-1");
    results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[\u0000 TO w]",
            null);
    assertEquals(2, results.length());
    results.close();
}