Author: natalia
Date: Fri Oct 19 17:35:10 2007
New Revision: 586648
URL: http://svn.apache.org/viewvc?rev=586648&view=rev
Log:
Tests for the new full text search XPath function
Modified:
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java
xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
Modified: xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java?rev=586648&r1=586647&r2=586648&view=diff
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java Fri Oct 19 17:35:10 2007
@@ -238,6 +238,21 @@
assertNotNull("Complex query didn't return a node", node);
}
+ public void testFullTextXPathQuery() throws Exception {
+ Object node = null;
+ XPathQueryResolver queryResolv = new XPathQueryResolver();
+ NodeSet nodeSet =
+ queryResolv.query(
+ col,
+ "/terrainmap/coordinates//node()[ftcontains('text')]/latitude/text()",
+ null,
+ null);
+ if (nodeSet.hasMoreNodes()) {
+ node = nodeSet.getNextNode();
+ }
+ assertNotNull("Full text query didn't return a node", node);
+ }
+
public void tearDown() throws Exception {
if (--tests == 0) {
db.dropCollection(col);
Modified: xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java?rev=586648&r1=586647&r2=586648&view=diff
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java Fri Oct 19 17:35:10 2007
@@ -316,10 +316,19 @@
*/
public void createIndex() throws Exception {
if (!itsIndexCreated) {
- client.createIndexer(COLLECTION_PATH,
- "<?xml version='1.0'?><index name='" + itsTestIndexName + "' " +
- "class='org.apache.xindice.core.indexer." + itsTestIndexType + "Indexer' " +
- "pattern='" + itsTestIndexPattern + "' />");
+ String config;
+ if ("Lucene".equals(itsTestIndexType)) {
+ config = "<?xml version='1.0'?><index name='" + itsTestIndexName + "' " +
+ "class='org.apache.xindice.core.indexer." + itsTestIndexType + "Indexer'>" +
+ "<pattern pattern='" + itsTestIndexPattern + "' alias=\"field\"/>" +
+ "</index>";
+ } else {
+ config = "<?xml version='1.0'?><index name='" + itsTestIndexName + "' " +
+ "class='org.apache.xindice.core.indexer." + itsTestIndexType + "Indexer' " +
+ "pattern='" + itsTestIndexPattern + "' />";
+ }
+
+ client.createIndexer(COLLECTION_PATH, config);
itsIndexCreated = true;
// Wait for the indexer to do the background indexing
@@ -874,6 +883,54 @@
"<number given='no' />" +
"</street>" +
"</address>"
+ });
+
+ aTest.runTest();
+ }
+
+ /**
+ * Tests an full text search query for an Element value that should be resolvable using
+ * indexed searching on a text index.
+ */
+ public void testSpecificElementNoAttributeTextIndexedSearch() throws Exception {
+ // search all records whose address is empty
+ IndexerTestDefinition aTest = new IndexerTestDefinition(
+ "testSpecificElementNoAttributeTextIndexedSearch", // description
+ "//person[info[ftcontains('text')]]/last[@surname = 'yes']", // query
+ "SENA", // index name
+ "Lucene", // index type
+ "info", // index pattern
+ 8, // indexed query speedup expected (conservative)
+ new String[] { // test docs specifically for this test
+ "<?xml version='1.0'?>" +
+ "<person number3='yes'>" +
+ "<first surname='no' given='yes'>Sally</first>" +
+ "<last surname='yes'>Smith</last>" +
+ "<phone call='no' type='work'>555-345-6789</phone>" +
+ "<address>" +
+ "<street>" +
+ "<number given='no' />" +
+ "</street>" +
+ "</address>" +
+ "<info>test test another test</info>" +
+ "</person>",
+
+ "<?xml version='1.0'?>" +
+ "<person number3='yes'>" +
+ "<first surname='no' given='yes'>Sally</first>" +
+ "<last surname='yes'>Smithers</last>" +
+ "<phone call='no' type='work'>555-345-6789</phone>" +
+ "<address>" +
+ "<street>" +
+ "<number given='no' />Main St" +
+ "</street>" +
+ "</address>" +
+ "<info>test test some more text</info>" +
+ "</person>"
+ },
+ 1, // expected result count
+ new Object[] { // expected resources to check for (can be empty or partial set)
+ new Integer(1), "<last surname='yes'>Smithers</last>"
});
aTest.runTest();
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.