use of indexing.Team in project play2-elasticsearch by cleverage.
the class Global method initTeams.
private void initTeams() {
// init Country
Country espagne = new Country();
espagne.name = "espagne";
espagne.continent = "europe";
Country france = new Country();
france.name = "france";
france.continent = "europe";
// init Team
Team barcelone = new Team();
barcelone.name = "FC Barcelone";
barcelone.country = espagne;
barcelone.level = "Ligua";
barcelone.dateCreate = new Date();
loadPlayersBarcelone(barcelone);
barcelone.index();
Team madrid = new Team();
madrid.name = "Real Madrid";
madrid.country = espagne;
madrid.level = "Ligua";
madrid.dateCreate = new Date();
loadPlayersMadrid(madrid);
madrid.index();
Team ol = new Team();
ol.name = "Olympique Lyonnais";
ol.country = france;
ol.level = "Ligue 1";
ol.dateCreate = new Date();
ol.index();
}
use of indexing.Team in project play2-elasticsearch by cleverage.
the class Application method index.
public static Result index() {
// ElasticSearch HelloWorld
IndexTest indexTest = new IndexTest();
// "id" is mandatory if you want to update your document or to get by id else "id" is not mandatory
indexTest.id = "1";
indexTest.name = "hello World";
indexTest.index();
IndexTest byId = IndexTest.find.byId("1");
IndexResults<IndexTest> all = IndexTest.find.all();
IndexQuery<IndexTest> indexQuery = IndexTest.find.query();
indexQuery.setBuilder(QueryBuilders.queryStringQuery("hello"));
IndexResults<IndexTest> indexResults = IndexTest.find.search(indexQuery);
// Team indexing
// search All
IndexResults<Team> allTeam = Team.find.all();
// search All + aggregation country
IndexQuery<Team> queryCountry = Team.find.query();
queryCountry.addAggregation(AggregationBuilders.terms("countryF").field("country.name"));
IndexResults<Team> allAndAggregationCountry = Team.find.search(queryCountry);
TermsAggregator countryF = allAndAggregationCountry.aggregations.get("countryF");
// search All + aggregation players.position
IndexQuery<Team> queryPlayers = Team.find.query();
queryPlayers.addAggregation(AggregationBuilders.terms("playersF").field("players.position"));
queryPlayers.addAggregation(AggregationBuilders.nested("players"));
IndexResults<Team> allAndAggregationAge = Team.find.search(queryPlayers);
return ok(index.render("Your new application is ready."));
}
Aggregations