Search in sources :

Example 21 with LindenFieldSchema

use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.

the class LindenUtil method parseDynamicFieldSchema.

public static LindenFieldSchema parseDynamicFieldSchema(String name) {
    LindenFieldSchema fieldSchema = new LindenFieldSchema();
    // Linden dynamic field is always indexed and stored
    fieldSchema.setStored(true);
    fieldSchema.setIndexed(true);
    fieldSchema.setDynamicSchema(true);
    int idx = name.lastIndexOf(LindenSchemaConf.DYNAMIC_TYPE_SEPARATOR);
    String tag = idx >= 0 ? name.substring(idx + 1) : "";
    switch(tag.toLowerCase()) {
        case LindenSchemaConf.INT:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.INTEGER);
            break;
        case LindenSchemaConf.LONG:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.LONG);
            break;
        case LindenSchemaConf.DOUBLE:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.DOUBLE);
            break;
        case LindenSchemaConf.FLOAT:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.FLOAT);
            break;
        case LindenSchemaConf.STRING:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.STRING);
            break;
        case LindenSchemaConf.FACET:
            fieldSchema.setName(name.substring(0, idx));
            fieldSchema.setType(LindenType.FACET);
            break;
        default:
            // default field type is STRING
            fieldSchema.setName(name);
            fieldSchema.setType(LindenType.STRING);
            break;
    }
    return fieldSchema;
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema)

Example 22 with LindenFieldSchema

use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.

the class BQLCompilerAnalyzer method getFieldNameAndType.

private Map.Entry<String, LindenType> getFieldNameAndType(String col) {
    LindenType type = fieldTypeMap.get(col);
    if (type != null) {
        return new AbstractMap.SimpleEntry<>(col, type);
    }
    LindenFieldSchema fieldSchema = LindenUtil.parseDynamicFieldSchema(col);
    return new AbstractMap.SimpleEntry<>(fieldSchema.getName(), fieldSchema.getType());
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenType(com.xiaomi.linden.thrift.common.LindenType)

Example 23 with LindenFieldSchema

use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.

the class TestHotSwapLindenCore method init.

public void init() throws Exception {
    LindenSchema schema = new LindenSchema().setId("id");
    schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setStored(true).setTokenized(true));
    lindenConfig = new LindenConfig();
    lindenConfig.setClusterUrl("127.0.0.1:2181/test");
    lindenConfig.setSchema(schema);
    String path = FilenameUtils.concat(TestMultiLindenCore.class.getResource("./").getPath(), "index/");
    FileUtils.deleteQuietly(new File(path));
    lindenConfig.setIndexDirectory(path);
    lindenConfig.setLindenCoreMode(LindenConfig.LindenCoreMode.HOTSWAP);
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema) File(java.io.File)

Example 24 with LindenFieldSchema

use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.

the class TestLindenAggregation method init.

@Override
public void init() throws Exception {
    LindenSchema schema = new LindenSchema().setId("id");
    schema.addToFields(new LindenFieldSchema().setName("intValue").setType(LindenType.INTEGER).setDocValues(true));
    lindenConfig.setSchema(schema);
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema)

Example 25 with LindenFieldSchema

use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.

the class TestLindenDynamicField method init.

@Override
public void init() {
    schema = new LindenSchema().setId("id");
    schema.addToFields(new LindenFieldSchema("name", LindenType.STRING).setIndexed(true).setTokenized(true).setStored(true));
    schema.addToFields(new LindenFieldSchema("level", LindenType.STRING).setIndexed(true).setStored(true));
    schema.addToFields(new LindenFieldSchema("log", LindenType.STRING).setIndexed(true).setTokenized(true).setStored(true));
    schema.addToFields(new LindenFieldSchema("host", LindenType.STRING).setIndexed(true).setStored(true));
    schema.addToFields(new LindenFieldSchema("shard", LindenType.INTEGER).setIndexed(true).setStored(true));
    lindenConfig.setSchema(schema);
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema)

Aggregations

LindenFieldSchema (com.xiaomi.linden.thrift.common.LindenFieldSchema)31 LindenSchema (com.xiaomi.linden.thrift.common.LindenSchema)17 LindenField (com.xiaomi.linden.thrift.common.LindenField)4 JSONObject (com.alibaba.fastjson.JSONObject)3 LindenDocument (com.xiaomi.linden.thrift.common.LindenDocument)3 IOException (java.io.IOException)3 JSONArray (com.alibaba.fastjson.JSONArray)2 Coordinate (com.xiaomi.linden.thrift.common.Coordinate)2 LindenType (com.xiaomi.linden.thrift.common.LindenType)2 Document (org.apache.lucene.document.Document)2 IndexableField (org.apache.lucene.index.IndexableField)2 Shape (com.spatial4j.core.shape.Shape)1 LindenValue (com.xiaomi.linden.thrift.common.LindenValue)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1