Package indextype

Examples of indextype.Index1Type1


                String name1 = "name1";
                String category = "category";
                Date date = new Date();

                // init new Type1
                Index1Type1 type1 = new Index1Type1();
                type1.name = name1;
                type1.category = category;
                type1.dateCreate = date;

                // this is to go around the known bug in elasticsearch 1.1:
                // https://github.com/elasticsearch/elasticsearch/issues/5680#issuecomment-39794200
                // Issue is fixed on ES 1.1.1
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                type1.location = location;

                // indexing
                IndexResponse index = type1.index();

                // Read
                Index1Type1 typeResult = Index1Type1.find.byId(index.getId());

                assertThat(typeResult).isNotNull();
                assertThat(typeResult.name).isEqualTo(name1);
                assertThat(typeResult.category).isEqualTo(category);
                assertThat(typeResult.dateCreate).isEqualTo(date);
                assertThat(typeResult.getIndexPath().index).isEqualTo("index1");
                assertThat(typeResult.getIndexPath().type).isEqualTo("type1");
            }
        });
    }
View Full Code Here


    @Test
    public void asynchronousIndex() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date());
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                index1Type1.location = location;

                Index1Type1 index1Type1Bis = new Index1Type1("2", "name2", "category", new Date());
                index1Type1Bis.location = location;

                F.Promise<IndexResponse> promise1 = index1Type1.indexAsync();
                F.Promise<IndexResponse> promise2 = index1Type1Bis.indexAsync();

                F.Promise<List<IndexResponse>> promise = F.Promise.sequence(promise1, promise2);
                List<IndexResponse> indexResponses = promise.get(10L, TimeUnit.SECONDS);
                assertThat(indexResponses.size()).isEqualTo(2);
            }
View Full Code Here

    public void asynchronousIndexBulk() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(),location);
                Index1Type1 index1Type1Bis = new Index1Type1("2", "name2", "category", new Date(),location);
                Index1Type1 index1Type1Ter = new Index1Type1("3", "name3", "category", new Date(),location);

                F.Promise<BulkResponse> promise = IndexService.indexBulkAsync(
                        index1Type1.getIndexPath(),
                        Arrays.asList(index1Type1, index1Type1Bis, index1Type1Ter)
                );
View Full Code Here

    public void asynchronousDelete() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(), location);
                Index1Type1 index1Type1Bis = new Index1Type1("2", "name2", "category", new Date(), location);
                Index1Type1 index1Type1Ter = new Index1Type1("3", "name3", "category", new Date(), location);
                IndexService.indexBulk(index1Type1.getIndexPath(), Arrays.asList(index1Type1, index1Type1Bis, index1Type1Ter));

                F.Promise<DeleteResponse> promise1 = index1Type1.deleteAsync();
                F.Promise<DeleteResponse> promise2 = index1Type1Bis.deleteAsync();
                F.Promise<DeleteResponse> promise3 = index1Type1Ter.deleteAsync();

                F.Promise<List<DeleteResponse>> promise = F.Promise.sequence(promise1, promise2, promise3);
                List<DeleteResponse> deleteResponses = promise.get(10L, TimeUnit.SECONDS);

                assertThat(deleteResponses.size()).isEqualTo(3);
View Full Code Here

    public void asynchronousGet() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(), location);
                Index1Type1 index1Type1Bis = new Index1Type1("2", "name2", "category", new Date(), location);
                Index1Type1 index1Type1Ter = new Index1Type1("3", "name3", "category", new Date(), location);
                IndexService.indexBulk(index1Type1.getIndexPath(), Arrays.asList(index1Type1, index1Type1Bis, index1Type1Ter));

                F.Promise<Index1Type1> promise1 = IndexService.getAsync(index1Type1.getIndexPath(), Index1Type1.class,  "1");
                F.Promise<Index1Type1> promise2 = IndexService.getAsync(index1Type1.getIndexPath(), Index1Type1.class,  "2");
                F.Promise<Index1Type1> promise3 = IndexService.getAsync(index1Type1.getIndexPath(), Index1Type1.class, "3");
View Full Code Here

    public void asynchronousSearch() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(), location);
                index1Type1.index();
                IndexService.refresh();

                IndexQuery<Index1Type1> query = new IndexQuery<Index1Type1>(Index1Type1.class);
                List<F.Promise<? extends IndexResults<Index1Type1>>> promises = new ArrayList<F.Promise<? extends IndexResults<Index1Type1>>>();
                for (int i = 0; i < 10; i++) {
                    promises.add(query.fetchAsync(index1Type1.getIndexPath()));
                }

                F.Promise<List<IndexResults<Index1Type1>>> combinedPromise = F.Promise.sequence(promises);
                List<IndexResults<Index1Type1>> indexResultsList = combinedPromise.get(10L, TimeUnit.SECONDS);
                assertThat(indexResultsList.size()).isEqualTo(10);
View Full Code Here

            @Override
            public void run() {
                // Blocking
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(),location);
                index1Type1.index();
                Map<String, Object> fieldNewValues = new HashMap<>();
                fieldNewValues.put("name", "new-name");
                String updateScript = "ctx._source.name = name";
                index1Type1.update(fieldNewValues, updateScript);

                Index1Type1 index1Type11 = Index1Type1.find.byId("1");
                assertThat(index1Type11.name).isEqualTo("new-name");

                // Async
                fieldNewValues.put("name","new-name-async");
                F.Promise<UpdateResponse> updateResponsePromise = index1Type1.updateAsync(fieldNewValues, updateScript);
View Full Code Here

    public void searchWithGeoFilter() {
        running(esFakeApplication(), new Runnable() {
            @Override
            public void run() {
                GeoPoint location = new GeoPoint(30.6943566,-88.0430541);
                Index1Type1 index1Type1 = new Index1Type1("1", "name1", "category", new Date(), location);
                index1Type1.index();

                location = new GeoPoint(12.6943566,-10.0430541);
                Index1Type1 index1Type2 = new Index1Type1("2", "name1", "category", new Date(), location);
                index1Type2.index();

                // refresh the index so the documents appear in the search results
                IndexService.refresh();

                assertThat(Index1Type1.find.byId("1").name).isEqualTo("name1");
View Full Code Here

TOP

Related Classes of indextype.Index1Type1

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.