Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.NodeSet


  }

    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);
    }
View Full Code Here


        assertTrue(count == 3);
    }

    public void testWildcardQuery3() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("test*");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 0);
    }
View Full Code Here

        assertTrue(count == 0);
    }

    public void testWildcardQuery4() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("s*d"); // matches "second" and "specified"

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 2);
    }
View Full Code Here

        assertTrue(count == 2);
    }

    public void testProximityQuery() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("\"java edition\"~5");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 1);
    }
View Full Code Here

        assertTrue(count == 1);
    }

    public void testFuzzyQuery() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("on~0.2"); // matches "on" and "in"

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 3);
    }
View Full Code Here

    public void testRangeQuery() throws Exception {
        doc = DOMParser.toDocument(str);
        list = doc.getDocumentElement().getElementsByTagName("title");

        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("{chapter TO part}");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 1);
    }
View Full Code Here

        }

        assertTrue(collection.getFiler().getRecordCount() == iterations);

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet result = service.query(collection, "//test1[starts-with(., '8')]", null, null);
        int count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }

        assertEquals(1, count);

        result = service.query(collection, "//test1[. < '8' or . > '8']", null, null);
        count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }

        assertEquals(9, count);
    }
View Full Code Here

        }

        assertTrue(collection.getFiler().getRecordCount() == iterations);

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet result = service.query(collection, "//test1[starts-with(../@num, '8')]", null, null);
        int count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }

        assertEquals(1, count);
    }
View Full Code Here

        collection.insertDocument("key1", DOMParser.toDocument("<test1>This <i>is</i> a test</test1>"));
        collection.insertDocument("key2", DOMParser.toDocument("<test2>This <i>is</i> a test</test2>"));
        assertEquals(2, collection.getFiler().getRecordCount());

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet result = service.query(collection, "//test2[starts-with(., 'This is')]", null, null);
        int count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }
        assertEquals(1, count);

        result = service.query(collection, "//test1[starts-with(., 'This is')]", null, null);
        count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }
        assertEquals(1, count);

    }
View Full Code Here

        collection.insertDocument("document", document);
        collection.insertBinary("binary", binary);

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet resultSet = service.query(collection, "/test", null, null);

        int resultCount = 0;
        while (resultSet.hasMoreNodes()) {
            resultSet.getNextNode();
            resultCount++;
        }

        assertEquals(1, resultCount);
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.data.NodeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.