private static String initializedId(IndexType indexType) { return indexType.getIndex() + "." + indexType.getType() + ".initialized"; }
DocId(IndexType indexType, String id) { this(indexType.getIndex(), indexType.getType(), id); }
/** * @return the identifier of the ElasticSearch type (including it's index name), that corresponds to a certain document type */ private static IndexType getAuthorizationIndexType(IndexType indexType) { requireNonNull(indexType); requireNonNull(indexType.getIndex()); checkArgument(!TYPE_AUTHORIZATION.equals(indexType.getType()), "Authorization types do not have authorization on their own."); return new IndexType(indexType.getIndex(), TYPE_AUTHORIZATION); }
private static IndexRequest newIndexRequest(IndexPermissions dto, IndexType indexType) { Map<String, Object> doc = new HashMap<>(); if (dto.isAllowAnyone()) { doc.put(IndexAuthorizationConstants.FIELD_ALLOW_ANYONE, true); // no need to feed users and groups } else { doc.put(IndexAuthorizationConstants.FIELD_ALLOW_ANYONE, false); doc.put(IndexAuthorizationConstants.FIELD_GROUP_IDS, dto.getGroupIds()); doc.put(IndexAuthorizationConstants.FIELD_USER_IDS, dto.getUserIds()); } return new IndexRequest(indexType.getIndex(), indexType.getType()) .id(dto.getProjectUuid()) .routing(dto.getProjectUuid()) .source(doc); }
private static BoolQueryBuilder buildTagsFilter(Collection<String> tags, OrganizationDto organization) { BoolQueryBuilder q = boolQuery(); tags.stream() .map(tag -> boolQuery() .filter(QueryBuilders.termQuery(FIELD_RULE_EXTENSION_TAGS, tag)) .filter(termsQuery(FIELD_RULE_EXTENSION_SCOPE, RuleExtensionScope.system().getScope(), RuleExtensionScope.organization(organization).getScope()))) .map(childQuery -> JoinQueryBuilders.hasChildQuery(INDEX_TYPE_RULE_EXTENSION.getType(), childQuery, ScoreMode.None)) .forEach(q::should); return q; }
private IndexRequest newIndexRequest(int intField) { return new IndexRequest(INDEX, INDEX_TYPE_FAKE.getType()) .source(ImmutableMap.of(FakeIndexDefinition.INT_FIELD, intField)); }
private static IndexRequest newIndexRequest(ViewDoc doc) { return new IndexRequest(ViewIndexDefinition.INDEX_TYPE_VIEW.getIndex(), ViewIndexDefinition.INDEX_TYPE_VIEW.getType(), doc.uuid()) .source(doc.getFields()); }
public IndexRequestBuilder prepareIndex(IndexType indexType) { return new ProxyIndexRequestBuilder(nativeClient()).setIndex(indexType.getIndex()).setType(indexType.getType()); }
@Test public void test_getAuthorizationScope() { AuthorizationScope scope = underTest.getAuthorizationScope(); assertThat(scope.getIndexType().getIndex()).isEqualTo(INDEX_TYPE_ISSUE.getIndex()); assertThat(scope.getIndexType().getType()).isEqualTo(TYPE_AUTHORIZATION); Predicate<IndexPermissions> projectPredicate = scope.getProjectPredicate(); IndexPermissions project = new IndexPermissions("P1", Qualifiers.PROJECT); IndexPermissions file = new IndexPermissions("F1", Qualifiers.FILE); assertThat(projectPredicate.test(project)).isTrue(); assertThat(projectPredicate.test(file)).isFalse(); }
private IndexRequest newIndexRequestWithDocId(String id) { return new IndexRequest(INDEX, INDEX_TYPE_FAKE.getType()) .id(id) .source(ImmutableMap.of(FakeIndexDefinition.INT_FIELD, 42)); } }
public GetRequestBuilder prepareGet(IndexType indexType, String id) { return new ProxyGetRequestBuilder(nativeClient()).setIndex(indexType.getIndex()).setType(indexType.getType()).setId(id); }
private static IndexRequest newIndexRequest(ProjectMeasuresDoc doc) { String projectUuid = doc.getId(); return new IndexRequest(INDEX_TYPE_PROJECT_MEASURES.getIndex(), INDEX_TYPE_PROJECT_MEASURES.getType(), projectUuid) .routing(projectUuid) .parent(projectUuid) .source(doc.getFields()); }
private static IndexRequest newRuleDocIndexRequest(RuleForIndexingDto ruleForIndexingDto) { RuleDoc doc = RuleDoc.of(ruleForIndexingDto); return new IndexRequest(INDEX_TYPE_RULE.getIndex(), INDEX_TYPE_RULE.getType()) .id(doc.getId()) .routing(doc.getRouting()) .source(doc.getFields()); }
private static IndexRequest newIndexRequest(ComponentDoc doc) { return new IndexRequest(INDEX_TYPE_COMPONENT.getIndex(), INDEX_TYPE_COMPONENT.getType(), doc.getId()) .routing(doc.getRouting()) .parent(doc.getParent()) .source(doc.getFields()); }
public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_METADATA.getIndex(), newBuilder(configuration) .setRefreshInterval(MANUAL_REFRESH_INTERVAL) .setDefaultNbOfShards(DEFAULT_NUMBER_OF_SHARDS) .build()); NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_METADATA.getType()); mapping.keywordFieldBuilder(FIELD_VALUE).disableSearch().store().build(); } }
private static IndexRequest newRuleExtensionDocIndexRequest(RuleForIndexingDto ruleForIndexingDto) { RuleExtensionDoc ruleExtensionDoc = RuleExtensionDoc.of(ruleForIndexingDto); return new IndexRequest(INDEX_TYPE_RULE_EXTENSION.getIndex(), INDEX_TYPE_RULE_EXTENSION.getType()) .id(ruleExtensionDoc.getId()) .routing(ruleExtensionDoc.getRouting()) .parent(ruleExtensionDoc.getParent()) .source(ruleExtensionDoc.getFields()); }
private static IndexRequest newRuleExtensionDocIndexRequest(RuleExtensionForIndexingDto ruleExtensionForIndexingDto) { RuleExtensionDoc doc = RuleExtensionDoc.of(ruleExtensionForIndexingDto); return new IndexRequest(INDEX_TYPE_RULE_EXTENSION.getIndex(), INDEX_TYPE_RULE_EXTENSION.getType()) .id(doc.getId()) .routing(doc.getRouting()) .parent(doc.getParent()) .source(doc.getFields()); }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create(INDEX, newBuilder(new MapSettings().asConfig()).build()); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, replicas); index.getSettings().put("index.refresh_interval", "-1"); NewIndex.NewIndexType type = index.createType(INDEX_TYPE_FAKE.getType()); type.createIntegerField(INT_FIELD); }
@Override public void define(IndexDefinitionContext context) { NewIndex index = context.create( INDEX_TYPE_VIEW.getIndex(), newBuilder(config) .setDefaultNbOfShards(5) .build()); // type "view" NewIndex.NewIndexType mapping = index.createType(INDEX_TYPE_VIEW.getType()); mapping.keywordFieldBuilder(FIELD_UUID).disableNorms().build(); mapping.keywordFieldBuilder(FIELD_PROJECTS).disableNorms().build(); } }
private static IndexRequest newIndexRequest(IndexedActiveRuleDto dto) { ActiveRuleDoc doc = new ActiveRuleDoc(dto.getId()) .setRuleId(dto.getRuleId()) .setRuleProfileUuid(dto.getRuleProfileUuid()) .setSeverity(SeverityUtil.getSeverityFromOrdinal(dto.getSeverity())); // all the fields must be present, even if value is null String inheritance = dto.getInheritance(); doc.setInheritance(inheritance == null ? ActiveRuleInheritance.NONE.name() : inheritance); return new IndexRequest(INDEX_TYPE_ACTIVE_RULE.getIndex(), INDEX_TYPE_ACTIVE_RULE.getType()) .id(doc.getId()) .parent(doc.getParent()) .routing(doc.getRouting()) .source(doc.getFields()); }