I can not change the display. Can someone help me find an error in my code?
I found this standard way to change the display according to several tutorials. But when I try to call the map structure, after creating the map manuall only the empty display structure appears.
But after inserting some data, a display specification appears, because ES uses, of course, by default. To be more specific, see the code below.
public class ElasticTest { private String dbname = "ElasticSearch"; private String index = "indextest"; private String type = "table"; private Client client = null; private Node node = null; public ElasticTest(){ this.node = nodeBuilder().local(true).node(); this.client = node.client(); if(isIndexExist(index)){ deleteIndex(this.client, index); createIndex(index); } else{ createIndex(index); } System.out.println("mapping structure before data insertion"); getMappings(); System.out.println("----------------------------------------"); createData(); System.out.println("mapping structure after data insertion"); getMappings(); } public void getMappings() { ClusterState clusterState = client.admin().cluster().prepareState() .setFilterIndices(index).execute().actionGet().getState(); IndexMetaData inMetaData = clusterState.getMetaData().index(index); MappingMetaData metad = inMetaData.mapping(type); if (metad != null) { try { String structure = metad.getSourceAsMap().toString(); System.out.println(structure); } catch (IOException e) { e.printStackTrace(); } } } private void createIndex(String index) { XContentBuilder typemapping = buildJsonMappings(); String mappingstring = null; try { mappingstring = buildJsonMappings().string(); } catch (IOException e1) { e1.printStackTrace(); } client.admin().indices().create(new CreateIndexRequest(index) .mapping(type, typemapping)).actionGet();
I just want to change the property of the ATTR1 field for analysis to provide quick queries. What am I doing wrong? I also tried to create a mapping after creating the index, but this leads to the same effect.
source share