/** * Parse a String generated by {@link #format()} */ public static IndexType parse(String s) { List<String> split = SEPARATOR_SPLITTER.splitToList(s); if (split.size() != 2) { throw new IllegalArgumentException("Unsupported IndexType value: " + s); } return new IndexType(split.get(0), split.get(1)); }
private static EsQueueDto newQueueDto(String docId, String docIdType, @Nullable String routing) { return EsQueueDto.create(INDEX_TYPE_ACTIVE_RULE.format(), docId, docIdType, routing); } }
/** * @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 List<String> loadExistingIndicesExceptMetadata(Collection<Index> definitions) { Set<String> definedNames = definitions.stream().map(IndexDefinition.Index::getName).collect(Collectors.toSet()); return Arrays.stream(client.nativeClient().admin().indices().prepareGetIndex().get().getIndices()) .filter(definedNames::contains) .filter(index -> !MetadataIndexDefinition.INDEX_TYPE_METADATA.getIndex().equals(index)) .collect(Collectors.toList()); } }
private static ListMultimap<IndexType, EsQueueDto> groupItemsByType(Collection<EsQueueDto> items) { return items.stream().collect(MoreCollectors.index(i -> IndexType.parse(i.getDocType()))); }
@Test public void equals_and_hashCode() { IndexType type1 = new IndexType("foo", "bar"); IndexType type1b = new IndexType("foo", "bar"); IndexType type2 = new IndexType("foo", "baz"); assertThat(type1.equals(type1)).isTrue(); assertThat(type1.equals(type1b)).isTrue(); assertThat(type1.equals(type2)).isFalse(); assertThat(type1.hashCode()).isEqualTo(type1.hashCode()); assertThat(type1.hashCode()).isEqualTo(type1b.hashCode()); } }
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; }
public SearchRequestBuilder prepareSearch(IndexType... indexType) { return new ProxySearchRequestBuilder(nativeClient()) .setIndices(IndexType.getIndices(indexType)) .setTypes(IndexType.getTypes(indexType)); }
public static String[] getIndices(IndexType... indexTypes) { return getDetails(IndexType::getIndex, indexTypes); }
/** * @return the identifier of the ElasticSearch type (including it's index name), that corresponds to a certain document type */ public static IndexType getAuthorizationIndexType(IndexType indexType) { requireNonNull(indexType); requireNonNull(indexType.getIndex()); checkArgument(!AuthorizationTypeSupport.TYPE_AUTHORIZATION.equals(indexType.getType()), "Authorization types do not have authorization on their own."); return new IndexType(indexType.getIndex(), AuthorizationTypeSupport.TYPE_AUTHORIZATION); }
private void setInitialized(IndexType indexType) { String index = indexType.getIndex(); waitForIndexYellow(index); metadataIndex.setInitialized(indexType, true); }
private static ListMultimap<IndexType, EsQueueDto> groupItemsByType(Collection<EsQueueDto> items) { return items.stream().collect(MoreCollectors.index(i -> IndexType.parse(i.getDocType()))); }
private IndexRequest newIndexRequest(int intField) { return new IndexRequest(INDEX, INDEX_TYPE_FAKE.getType()) .source(ImmutableMap.of(FakeIndexDefinition.INT_FIELD, intField)); }
public SearchRequestBuilder prepareSearch(IndexType... indexType) { return new ProxySearchRequestBuilder(nativeClient()) .setIndices(IndexType.getIndices(indexType)) .setTypes(IndexType.getTypes(indexType)); }
public static String[] getTypes(IndexType... indexTypes) { return getDetails(IndexType::getType, indexTypes); }
private static EsQueueDto createQueueDto(String docId, String docIdType, String projectUuid) { return EsQueueDto.create(INDEX_TYPE_ISSUE.format(), docId, docIdType, projectUuid); }
public long countDocuments(String index, String type) { return countDocuments(new IndexType(index, type)); }