use of org.elasticsearch.client.indices.GetFieldMappingsRequest in project LinkAgent by shulieTech.
the class GetFieldMappingsRequestIndexRename method reindex0.
@Override
public List<String> reindex0(Object target) {
GetFieldMappingsRequest req = (GetFieldMappingsRequest) target;
String[] indexes = req.indices();
for (int i = 0, len = indexes.length; i < len; i++) {
String index = indexes[i];
/**
* 如果在白名单中则不允许写
*/
if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
continue;
}
if (!Pradar.isClusterTestPrefix(index)) {
index = Pradar.addClusterTestPrefixLower(index);
indexes[i] = index;
}
}
req.indices(indexes);
return Arrays.asList(indexes);
}
use of org.elasticsearch.client.indices.GetFieldMappingsRequest in project spring-data-elasticsearch by spring-projects.
the class RequestConverters method getFieldMapping.
public static Request getFieldMapping(GetFieldMappingsRequest getFieldMappingsRequest) {
String[] indices = getFieldMappingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.indices();
String[] fields = getFieldMappingsRequest.fields() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.fields();
final String endpoint = new EndpointBuilder().addCommaSeparatedPathParts(indices).addPathPartAsIs("_mapping").addPathPartAsIs("field").addCommaSeparatedPathParts(fields).build();
Request request = new Request(HttpMethod.GET.name(), endpoint);
RequestConverters.Params parameters = new Params(request);
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults());
return request;
}
use of org.elasticsearch.client.indices.GetFieldMappingsRequest in project jackrabbit-oak by apache.
the class ElasticSimilarQueryTest method vectorSimilarityElastiknnIndexConfiguration.
@Test
public void vectorSimilarityElastiknnIndexConfiguration() throws Exception {
final String indexName = "test1";
final String fieldName1 = "fv1";
final String similarityFieldName1 = FieldNames.createSimilarityFieldName(fieldName1);
IndexDefinitionBuilder builder = createIndex(fieldName1);
Tree tree = builder.indexRule("nt:base").property(fieldName1).useInSimilarity(true).nodeScopeIndex().similaritySearchDenseVectorSize(2048).getBuilderTree();
tree.setProperty(ElasticPropertyDefinition.PROP_INDEX_SIMILARITY, "cosine");
tree.setProperty(ElasticPropertyDefinition.PROP_NUMBER_OF_HASH_TABLES, 10);
tree.setProperty(ElasticPropertyDefinition.PROP_NUMBER_OF_HASH_FUNCTIONS, 12);
setIndex(indexName, builder);
root.commit();
String alias = ElasticIndexNameHelper.getElasticSafeIndexName(esConnection.getIndexPrefix(), "/oak:index/" + indexName);
GetFieldMappingsRequest fieldMappingsRequest = new GetFieldMappingsRequest();
fieldMappingsRequest.indices(alias).fields(similarityFieldName1);
GetFieldMappingsResponse mappingsResponse = esConnection.getClient().indices().getFieldMapping(fieldMappingsRequest, RequestOptions.DEFAULT);
final Map<String, Map<String, GetFieldMappingsResponse.FieldMappingMetadata>> mappings = mappingsResponse.mappings();
assertEquals("More than one index found", 1, mappings.keySet().size());
@SuppressWarnings("unchecked") Map<String, Object> map1 = (Map<String, Object>) (((Map<String, Object>) mappings.entrySet().iterator().next().getValue().get(similarityFieldName1).sourceAsMap().get(similarityFieldName1)).get("elastiknn"));
assertEquals("Dense vector size doesn't match", 2048, (int) map1.get("dims"));
assertEquals("Similarity doesn't match", "cosine", map1.get("similarity"));
assertEquals("Similarity doesn't match", 10, map1.get("L"));
assertEquals("Similarity doesn't match", 12, map1.get("k"));
}
use of org.elasticsearch.client.indices.GetFieldMappingsRequest in project SOS by 52North.
the class SosElasticsearchSchemasTest method createSchema.
@Test
@Ignore
public void createSchema() throws IOException {
SosElasticsearchSchemas sch = new SosElasticsearchSchemas();
Map<String, Object> map = new HashMap<>();
map.put(type, sch.getSchema());
getEmbeddedClient().indices().create(new CreateIndexRequest(idx).mapping(map), RequestOptions.DEFAULT);
GetFieldMappingsResponse resp = getEmbeddedClient().indices().getFieldMapping(new GetFieldMappingsRequest().indices(idx).fields(type), RequestOptions.DEFAULT);
Assert.assertNotNull(resp.mappings());
}
use of org.elasticsearch.client.indices.GetFieldMappingsRequest in project SOS by 52North.
the class SosElasticsearchSchemasTest method createMetaDataSchema.
@Test
@Ignore
public void createMetaDataSchema() throws IOException {
SosElasticsearchSchemas sch = new SosElasticsearchSchemas();
Map<String, Object> map = new HashMap<>();
map.put(type, sch.getMetadataSchema());
getEmbeddedClient().indices().create(new CreateIndexRequest(idx).mapping(map), RequestOptions.DEFAULT);
GetFieldMappingsResponse resp = getEmbeddedClient().indices().getFieldMapping(new GetFieldMappingsRequest().indices(idx).fields(type), RequestOptions.DEFAULT);
Assert.assertNotNull(resp.mappings());
}
Aggregations