Search in sources :

Example 1 with TextMapping

use of org.webpieces.elasticsearch.mapping.TextMapping in project webpieces by deanhiller.

the class TestElasticStuff method testMappings.

@Test
public void testMappings() throws InterruptedException, ExecutionException, IOException, TimeoutException {
    TextMapping name = new TextMapping();
    Map<String, PropertyMapping> dataSourceProps = new HashMap<String, PropertyMapping>();
    dataSourceProps.put("name", name);
    ObjectMapping dataSource = new ObjectMapping();
    dataSource.setProperties(dataSourceProps);
    Map<String, PropertyMapping> properties = new HashMap<String, PropertyMapping>();
    properties.put("dataSource", dataSource);
    properties.put("dbCreatedAt", new DateMapping());
    properties.put("dbUpdatedAt", new DateMapping());
    Mappings mappings = new Mappings();
    mappings.setProperties(properties);
    ElasticIndex index = new ElasticIndex();
    index.setMappings(mappings);
    String s = mapper.writeValueAsString(index);
    System.out.println("json=" + s);
}
Also used : ObjectMapping(org.webpieces.elasticsearch.mapping.ObjectMapping) ElasticIndex(org.webpieces.elasticsearch.mapping.ElasticIndex) DateMapping(org.webpieces.elasticsearch.mapping.DateMapping) TextMapping(org.webpieces.elasticsearch.mapping.TextMapping) Mappings(org.webpieces.elasticsearch.mapping.Mappings) HashMap(java.util.HashMap) PropertyMapping(org.webpieces.elasticsearch.mapping.PropertyMapping) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 DateMapping (org.webpieces.elasticsearch.mapping.DateMapping)1 ElasticIndex (org.webpieces.elasticsearch.mapping.ElasticIndex)1 Mappings (org.webpieces.elasticsearch.mapping.Mappings)1 ObjectMapping (org.webpieces.elasticsearch.mapping.ObjectMapping)1 PropertyMapping (org.webpieces.elasticsearch.mapping.PropertyMapping)1 TextMapping (org.webpieces.elasticsearch.mapping.TextMapping)1