Example usage for java.util Locale ITALIAN

List of usage examples for java.util Locale ITALIAN

Introduction

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

Prototype

Locale ITALIAN

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem2ActionPerformed
    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. simplified chinese)
    if (false == Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            String country = Locale.TRADITIONAL_CHINESE.getCountry().equals(Locale.getDefault().getCountry())
                    ? Locale.SIMPLIFIED_CHINESE.getCountry()
                    : Locale.getDefault().getCountry();
            final Locale locale = new Locale(Locale.SIMPLIFIED_CHINESE.getLanguage(), country,
                    Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {/*  www .  jav a  2 s  .c  om*/
            if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem1.setSelected(true);
            } else if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem4.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.GERMAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem3.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.ITALIAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem5.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.FRENCH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem6.setSelected(true);
            }
        }
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem3ActionPerformed
    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. german)
    if (false == this.jStockOptions.getLocale().getLanguage().equals(Locale.GERMAN.getLanguage())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            final Locale locale = new Locale(Locale.GERMAN.getLanguage(), Locale.getDefault().getCountry(),
                    Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {//from   ww w. j  a  v  a  2 s.  c  o  m
            if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem1.setSelected(true);
            } else if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem4.setSelected(true);
            } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem2.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.ITALIAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem5.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.FRENCH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem6.setSelected(true);
            }
        }
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem4ActionPerformed
    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. german)
    if (false == Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            // Unline simplified chinese, we will not use Locale.getDefault().getCountry().
            // Instead, we will be using Locale.TRADITIONAL_CHINESE.getCountry().
            final Locale locale = new Locale(Locale.TRADITIONAL_CHINESE.getLanguage(),
                    Locale.TRADITIONAL_CHINESE.getCountry(), Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {/*from   w  ww  .ja va 2 s  .  c  o m*/
            if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem1.setSelected(true);
            } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem2.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.GERMAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem3.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.ITALIAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem5.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.FRENCH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem6.setSelected(true);
            }
        }
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem5ActionPerformed
    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. german)
    if (false == this.jStockOptions.getLocale().getLanguage().equals(Locale.ITALIAN.getLanguage())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            final Locale locale = new Locale(Locale.ITALIAN.getLanguage(), Locale.getDefault().getCountry(),
                    Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {//from w w w. j  a  v a 2 s .  c o  m
            if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem1.setSelected(true);
            } else if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem4.setSelected(true);
            } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem2.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.GERMAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem3.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.FRENCH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem6.setSelected(true);
            }
        }
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem6ActionPerformed
    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. german)
    if (false == this.jStockOptions.getLocale().getLanguage().equals(Locale.FRENCH.getLanguage())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            final Locale locale = new Locale(Locale.FRENCH.getLanguage(), Locale.getDefault().getCountry(),
                    Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {/*from   w  w w  .j  a v a  2s .  c o m*/
            if (this.jStockOptions.getLocale().getLanguage().compareTo(Locale.ENGLISH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem1.setSelected(true);
            } else if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem4.setSelected(true);
            } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem2.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.ITALIAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem5.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.GERMAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem3.setSelected(true);
            }
        }
    }
}

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

private void runBaseTests() throws LuceneIndexException, IOException {
    ADMLuceneSearcherImpl searcher = buildSearcher();
    ResultSet results;//from w w  w .j a v a  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();
}