Package com.basho.riak.client.core.query.search

Examples of com.basho.riak.client.core.query.search.YokozunaIndex


   
    @Test
    public void testStoreAndFetchIndex() throws InterruptedException, ExecutionException
    {
        Assume.assumeTrue(testYokozuna);
        YokozunaIndex index = new YokozunaIndex("test_index");
        YzPutIndexOperation putOp = new YzPutIndexOperation.Builder(index).build();
       
        cluster.execute(putOp);
        putOp.get();
       
        assertTrue("Index not created", assureIndexExists("test_index"));
       
       
        YzFetchIndexOperation fetchOp =
            new YzFetchIndexOperation.Builder().withIndexName("test_index")
                .build();
       
        cluster.execute(fetchOp);
        fetchOp.await();
        if (!fetchOp.isSuccess())
        {
            assertTrue(fetchOp.cause().toString(), fetchOp.isSuccess());
        }
       
        List<YokozunaIndex> indexList = fetchOp.get().getIndexes();
       
        assertFalse(indexList.isEmpty());
        index = indexList.get(0);
        assertEquals(index.getSchema(), "_yz_default");
       
        YzDeleteIndexOperation delOp = new YzDeleteIndexOperation.Builder("test_index").build();
        cluster.execute(delOp);
        delOp.await();
        assertTrue(delOp.isSuccess());
View Full Code Here


   
    @Test
    public void testDeleteIndex() throws InterruptedException, ExecutionException
    {
        Assume.assumeTrue(testYokozuna);
        YokozunaIndex index = new YokozunaIndex("test_index5");
        YzPutIndexOperation putOp = new YzPutIndexOperation.Builder(index).build();
       
        cluster.execute(putOp);
        putOp.get();
       
View Full Code Here

        Assume.assumeTrue(testBucketType);
       
        // First we have to create an index and attach it to a bucket
        // and the 'default' bucket type can't be used for search
       
        YokozunaIndex index = new YokozunaIndex("test_mr_index");
        StoreIndex ssi = new StoreIndex.Builder(index).build();
        client.execute(ssi);
       
        assertTrue("Index not created", assureIndexExists("test_mr_index"));
       
        Namespace ns = new Namespace(bucketType.toString(), mrBucketName);
        StoreBucketProperties sbp = new StoreBucketProperties.Builder(ns)
                                    .withSearchIndex(index.getName())
                                    .build();
        client.execute(sbp);
       
        RiakObject ro = new RiakObject()
                        .setContentType("application/json")
                        .setValue(BinaryValue.create("{\"name_s\":\"Lion-o\", \"age_i\":30, \"leader_b\":true}"));
        Location location = new Location(ns, "liono");
        StoreValue sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Cheetara\", \"age_i\":28, \"leader_b\":false}"));
        location = new Location(ns, "cheetara");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Snarf\", \"age_i\":43}"));
        location = new Location(ns, "snarf");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Panthro\", \"age_i\":36}"));
        location = new Location(ns, "panthro");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        // Sleep some more or ... yeah, it doesn't work.
        Thread.sleep(3000);
       
        SearchMapReduce smr = new SearchMapReduce.Builder()
                            .withIndex(index.getName())
                            .withQuery("NOT leader_b:true")
                            .withMapPhase(Function.newAnonymousJsFunction("function(v) { return [1]; }"), false)
                            .withReducePhase(Function.newNamedJsFunction("Riak.reduceSum"), true)
                            .build();
       
View Full Code Here

       
        // First we have to create an index and attach it to a bucket
        // and the 'default' bucket type can't be used for search
       
        BinaryValue searchBucket = BinaryValue.create("search_bucket");
        YokozunaIndex index = new YokozunaIndex("test_index");
        YzPutIndexOperation putOp = new YzPutIndexOperation.Builder(index).build();
       
        cluster.execute(putOp);
        putOp.await();
       
View Full Code Here

        RiakYokozunaPB.RpbYokozunaIndexGetResp response = rawResponse.get(0);
        List<YokozunaIndex> indexList = new ArrayList<YokozunaIndex>(response.getIndexCount());
       
        for (RiakYokozunaPB.RpbYokozunaIndex pbIndex : response.getIndexList())
        {
            indexList.add(new YokozunaIndex(pbIndex.getName().toStringUtf8(),
                                            pbIndex.getSchema().toStringUtf8()));
        }
       
        return new Response(indexList);
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.search.YokozunaIndex

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.