Package de.spinscale.elasticsearch.action.suggest.statistics

Examples of de.spinscale.elasticsearch.action.suggest.statistics.FstStats


        List<Map<String, Object>> products = createProducts("ProductName",
                "BMW 318", "BMW 528", "BMW M3", "the BMW 320", "VW Jetta");
        indexProducts(products);

        FstStats emptyFstStats = getStatistics();
        assertThat(emptyFstStats.getStats(), hasSize(0));
        assertThat(getFstSizeSum(emptyFstStats), equalTo(0L));

        SuggestionQuery query = new SuggestionQuery(index, type, "ProductName.keyword", "b")
                .suggestType("full").analyzer("stop").size(10);
        List<String> suggestions = getSuggestions(query);
        assertSuggestions(suggestions, "BMW 318", "BMW 528", "BMW M3", "the BMW 320");

        FstStats filledFstStats = getStatistics();
        assertThat(filledFstStats.getStats(), hasSize(greaterThanOrEqualTo(1)));

        List<FstStats.FstIndexShardStats> allStats = Lists.newArrayList(filledFstStats.getStats());
        assertThat(allStats.get(0).getShardId().id(), greaterThanOrEqualTo(0));
        assertThat(getFstSizeSum(filledFstStats), greaterThan(0L));
    }
View Full Code Here


        assertThat(r.getStatusCode(), is(200));
        System.out.println(r.getResponseBody());

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode rootObj = objectMapper.readTree(r.getResponseBody());
        FstStats fstStats = new FstStats();
        ArrayNode jsonFstStats = (ArrayNode) rootObj.get("fstStats");
        Iterator<JsonNode> nodesIterator = jsonFstStats.iterator();

        while (nodesIterator.hasNext()) {
            JsonNode fstStatsNodeEntry =  nodesIterator.next();

            if (fstStatsNodeEntry.isObject()) {
                ShardId shardId = new ShardId(fstStatsNodeEntry.get("index").asText(), fstStatsNodeEntry.get("id").asInt());
                FstStats.FstIndexShardStats fstIndexShardStats = new FstStats.FstIndexShardStats(shardId, null, null, fstStatsNodeEntry.get("sizeInBytes").getLongValue());
                stats.add(fstIndexShardStats);
            }

            fstStats.getStats().addAll(stats);

        }

        return fstStats;
    }
View Full Code Here

TOP

Related Classes of de.spinscale.elasticsearch.action.suggest.statistics.FstStats

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.