use of org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder in project sonarqube by SonarSource.
the class ProxyCreateIndexRequestBuilderTest method create_index.
@Test
public void create_index() {
CreateIndexRequestBuilder requestBuilder = esTester.client().prepareCreate(generateNewIndexName());
requestBuilder.get();
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder in project elasticsearch-opennlp-plugin by spinscale.
the class OpenNlpPluginIntegrationTest method startNode.
@Before
public void startNode() throws Exception {
node = createNode(clusterName).start();
CreateIndexResponse createIndexResponse = new CreateIndexRequestBuilder(node.client().admin().indices()).setIndex(index).execute().actionGet();
assertThat(createIndexResponse.isAcknowledged(), is(true));
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder in project elasticsearch by elastic.
the class MoreLikeThisIT method testSimpleMoreLikeThisIdsMultipleTypes.
public void testSimpleMoreLikeThisIdsMultipleTypes() throws Exception {
logger.info("Creating index test");
int numOfTypes = randomIntBetween(2, 10);
CreateIndexRequestBuilder createRequestBuilder = prepareCreate("test");
for (int i = 0; i < numOfTypes; i++) {
createRequestBuilder.addMapping("type" + i, jsonBuilder().startObject().startObject("type" + i).startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().endObject());
}
assertAcked(createRequestBuilder);
logger.info("Running Cluster Health");
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
logger.info("Indexing...");
List<IndexRequestBuilder> builders = new ArrayList<>(numOfTypes);
for (int i = 0; i < numOfTypes; i++) {
builders.add(client().prepareIndex("test", "type" + i).setSource("text", "lucene" + " " + i).setId(String.valueOf(i)));
}
indexRandom(true, builders);
logger.info("Running MoreLikeThis");
MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery(new String[] { "text" }, null, new Item[] { new Item("test", "type0", "0") }).include(true).minTermFreq(1).minDocFreq(1);
String[] types = new String[numOfTypes];
for (int i = 0; i < numOfTypes; i++) {
types[i] = "type" + i;
}
SearchResponse mltResponse = client().prepareSearch().setTypes(types).setQuery(queryBuilder).execute().actionGet();
assertHitCount(mltResponse, numOfTypes);
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder in project elasticsearch by elastic.
the class MultiMatchQueryIT method init.
@Before
public void init() throws Exception {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).put("index.analysis.analyzer.perfect_match.type", "custom").put("index.analysis.analyzer.perfect_match.tokenizer", "keyword").put("index.analysis.analyzer.perfect_match.filter", "lowercase").put("index.analysis.analyzer.category.type", "custom").put("index.analysis.analyzer.category.tokenizer", "whitespace").put("index.analysis.analyzer.category.filter", "lowercase"));
assertAcked(builder.addMapping("test", createMapping()));
ensureGreen();
int numDocs = scaledRandomIntBetween(50, 100);
List<IndexRequestBuilder> builders = new ArrayList<>();
builders.add(client().prepareIndex("test", "test", "theone").setSource("full_name", "Captain America", "first_name", "Captain", "last_name", "America", "category", "marvel hero", "skill", 15, "int-field", 25));
builders.add(client().prepareIndex("test", "test", "theother").setSource("full_name", "marvel hero", "first_name", "marvel", "last_name", "hero", "category", "bogus", "skill", 5));
builders.add(client().prepareIndex("test", "test", "ultimate1").setSource("full_name", "Alpha the Ultimate Mutant", "first_name", "Alpha the", "last_name", "Ultimate Mutant", "category", "marvel hero", "skill", 1));
builders.add(client().prepareIndex("test", "test", "ultimate2").setSource("full_name", "Man the Ultimate Ninja", "first_name", "Man the Ultimate", "last_name", "Ninja", "category", "marvel hero", "skill", 3));
builders.add(client().prepareIndex("test", "test", "anotherhero").setSource("full_name", "ultimate", "first_name", "wolferine", "last_name", "", "category", "marvel hero", "skill", 1));
builders.add(client().prepareIndex("test", "test", "nowHero").setSource("full_name", "now sort of", "first_name", "now", "last_name", "", "category", "marvel hero", "skill", 1));
List<String> firstNames = new ArrayList<>();
fill(firstNames, "Captain", between(15, 25));
fill(firstNames, "Ultimate", between(5, 10));
fillRandom(firstNames, between(3, 7));
List<String> lastNames = new ArrayList<>();
fill(lastNames, "Captain", between(3, 7));
fillRandom(lastNames, between(30, 40));
for (int i = 0; i < numDocs; i++) {
String first = RandomPicks.randomFrom(random(), firstNames);
String last = randomPickExcept(lastNames, first);
builders.add(client().prepareIndex("test", "test", "" + i).setSource("full_name", first + " " + last, "first_name", first, "last_name", last, "category", randomBoolean() ? "marvel hero" : "bogus", "skill", between(1, 3)));
}
indexRandom(true, false, builders);
}
use of org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder in project elasticsearch by elastic.
the class QueryStringIT method setupIndexWithGraph.
private void setupIndexWithGraph(String index) throws Exception {
CreateIndexRequestBuilder builder = prepareCreate(index).setSettings(Settings.builder().put(indexSettings()).put("index.analysis.filter.graphsyns.type", "synonym_graph").putArray("index.analysis.filter.graphsyns.synonyms", "wtf, what the fudge", "foo, bar baz").put("index.analysis.analyzer.lower_graphsyns.type", "custom").put("index.analysis.analyzer.lower_graphsyns.tokenizer", "standard").putArray("index.analysis.analyzer.lower_graphsyns.filter", "lowercase", "graphsyns"));
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(index).startObject("properties").startObject("field").field("type", "text").endObject().endObject().endObject().endObject();
assertAcked(builder.addMapping(index, mapping));
ensureGreen();
List<IndexRequestBuilder> builders = new ArrayList<>();
builders.add(client().prepareIndex(index, index, "1").setSource("field", "say wtf happened foo"));
builders.add(client().prepareIndex(index, index, "2").setSource("field", "bar baz what the fudge man"));
builders.add(client().prepareIndex(index, index, "3").setSource("field", "wtf"));
builders.add(client().prepareIndex(index, index, "4").setSource("field", "what is the name for fudge"));
builders.add(client().prepareIndex(index, index, "5").setSource("field", "bar two three"));
builders.add(client().prepareIndex(index, index, "6").setSource("field", "bar baz two three"));
indexRandom(true, false, builders);
}
Aggregations