Search in sources :

Example 1 with IndexField

use of org.frameworkset.elasticsearch.entity.IndexField in project bboss-elastic by bbossgroups.

the class BuildTool method buildIndexField.

public static IndexField buildIndexField(Map.Entry<String, Object> field, List<IndexField> fields, String parentFieldName) {
    // Map.Entry<String,Object> field = fileds.next();
    IndexField indexField = new IndexField();
    String fieldName = null;
    if (parentFieldName != null) {
        fieldName = parentFieldName + "." + field.getKey();
    } else {
        fieldName = field.getKey();
    }
    indexField.setFieldName(fieldName);
    Map<String, Object> fieldInfo = (Map<String, Object>) field.getValue();
    indexField.setType((String) fieldInfo.get("type"));
    indexField.setIgnoreAbove(ResultUtil.intValue(fieldInfo.get("ignore_above"), null));
    indexField.setAnalyzer((String) fieldInfo.get("analyzer"));
    indexField.setNormalizer((String) fieldInfo.get("normalizer"));
    indexField.setBoost(fieldInfo.get("boost"));
    indexField.setCoerce(parseBoolean(fieldInfo.get("coerce")));
    indexField.setCopyTo(fieldInfo.get("copy_to"));
    // setCoerce();
    indexField.setDocValues(parseBoolean(fieldInfo.get("doc_values")));
    // dynamic
    indexField.setDynamic(parseBoolean(fieldInfo.get("doc_values")));
    // enabled
    indexField.setEnabled(parseBoolean(fieldInfo.get("enabled")));
    // fielddata
    indexField.setFielddata(parseBoolean(fieldInfo.get("fielddata")));
    // format
    indexField.setFormat((String) fieldInfo.get("format"));
    // Coerce();	//		ignore_malformed
    indexField.setIgnoreMalformed(parseBoolean(fieldInfo.get("ignore_malformed")));
    // include_in_all
    indexField.setIncludeInAll(parseBoolean(fieldInfo.get("include_in_all")));
    indexField.setIndexOptions((String) fieldInfo.get("index_options"));
    // 
    indexField.setIndex(parseBoolean(fieldInfo.get("index")));
    // 
    indexField.setFields((Map<String, Object>) fieldInfo.get("fields"));
    // norms
    indexField.setNorms(parseBoolean(fieldInfo.get("norms")));
    // 
    indexField.setNullValue(fieldInfo.get("null_value"));
    indexField.setPositionIncrementGap((Integer) fieldInfo.get("position_increment_gap"));
    // 
    indexField.setProperties((Map<String, Object>) fieldInfo.get("properties"));
    // search_analyzer
    indexField.setSearchAnalyzer((String) fieldInfo.get("search_analyzer"));
    // 
    indexField.setSimilarity((String) fieldInfo.get("similarity"));
    // store
    indexField.setStore(parseBoolean(fieldInfo.get("store")));
    // 
    indexField.setTermVector((String) fieldInfo.get("term_vector"));
    fields.add(indexField);
    handleFields(indexField.getFields(), fieldName, fields);
    return indexField;
}
Also used : IndexField(org.frameworkset.elasticsearch.entity.IndexField)

Example 2 with IndexField

use of org.frameworkset.elasticsearch.entity.IndexField in project bboss-elastic by bbossgroups.

the class ESTest method testQueryDocMapping.

@Test
public void testQueryDocMapping() {
    ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil();
    System.out.println(clientUtil.getIndexMapping("trace-*", true));
    final List<IndexField> fields = clientUtil.getIndexMappingFields("trace-*", "trace");
    System.out.println(fields.size());
}
Also used : ClientInterface(org.frameworkset.elasticsearch.client.ClientInterface) IndexField(org.frameworkset.elasticsearch.entity.IndexField) Test(org.junit.Test)

Example 3 with IndexField

use of org.frameworkset.elasticsearch.entity.IndexField in project bboss-elastic by bbossgroups.

the class BuildTool method handleFields.

/**
 *	public static void evalBuilk( Writer writer,String indexName, String indexType, Object param, String action,String docIdField,String parentIdField,boolean upper7) throws IOException {
 *
 *		if (param != null) {
 *			buildMetaWithDocIdField(  writer ,  indexType,  indexName,   param,action,docIdField,parentIdField,  upper7);
 *			if(!action.equals("update")) {
 *				SerialUtil.object2json(param,writer);
 *				writer.write("\n");
 *			}
 *			else
 *			{
 *				writer.write("{\"doc\":");
 *				SerialUtil.object2json(param,writer);
 *				writer.write("}\n");
 *			}
 *		}
 *
 *	}
 */
public static void handleFields(Map<String, Object> subFileds, String fieldName, List<IndexField> fields) {
    if (subFileds == null || subFileds.size() == 0)
        return;
    Iterator<Map.Entry<String, Object>> iterator = subFileds.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<String, Object> entry = iterator.next();
        IndexField indexField = buildIndexField(entry, fields, fieldName);
    }
}
Also used : IndexField(org.frameworkset.elasticsearch.entity.IndexField)

Aggregations

IndexField (org.frameworkset.elasticsearch.entity.IndexField)3 ClientInterface (org.frameworkset.elasticsearch.client.ClientInterface)1 Test (org.junit.Test)1