Search in sources :

Example 31 with LindenFieldSchema

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

the class LindenScoreModelStrategy method preProcess.

public void preProcess(AtomicReaderContext context, LindenSchema schema, LindenScoreModel scoreModel) {
    this.context = context;
    fieldSchemaMap = new HashMap<>();
    for (LindenFieldSchema fieldSchema : schema.getFields()) {
        fieldSchemaMap.put(fieldSchema.getName(), fieldSchema);
    }
    // add id field
    if (!fieldSchemaMap.containsKey(schema.getId())) {
        LindenFieldSchema idFieldSchema = new LindenFieldSchema();
        idFieldSchema.setName(schema.getId());
        idFieldSchema.setType(LindenType.STRING);
        idFieldSchema.setIndexed(true);
        idFieldSchema.setOmitNorms(true);
        idFieldSchema.setOmitFreqs(true);
        idFieldSchema.setStored(true);
        idFieldSchema.setTokenized(false);
        fieldSchemaMap.put(schema.getId(), idFieldSchema);
    }
    this.scoreModel = scoreModel;
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema)

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