Search in sources :

Example 6 with VisualType

use of com.qlangtech.tis.runtime.module.misc.VisualType in project tis by qlangtech.

the class ParseResult method serialTypes.

/**
 * @param
 * @throws JSONException
 */
@Override
public com.alibaba.fastjson.JSONArray serialTypes() {
    com.alibaba.fastjson.JSONArray types = new com.alibaba.fastjson.JSONArray();
    com.alibaba.fastjson.JSONObject f = null;
    com.alibaba.fastjson.JSONArray tokens = null;
    com.alibaba.fastjson.JSONObject tt = null;
    SolrFieldsParser.SolrType solrType = null;
    // Set<String> typesSet = new HashSet<String>();
    for (Map.Entry<String, VisualType> t : TokenizerType.visualTypeMap.entrySet()) {
        f = new com.alibaba.fastjson.JSONObject();
        f.put("name", t.getKey());
        f.put("split", t.getValue().isSplit());
        tokens = new com.alibaba.fastjson.JSONArray();
        if (t.getValue().isSplit()) {
            // 默认类型
            for (ISearchEngineTokenizerType tokenType : t.getValue().getTokenerTypes()) {
                tt = new com.alibaba.fastjson.JSONObject();
                tt.put("key", tokenType.getKey());
                tt.put("value", tokenType.getDesc());
                tokens.add(tt);
            }
            // 外加类型
            for (Map.Entry<String, SolrFieldsParser.SolrType> entry : this.types.entrySet()) {
                solrType = entry.getValue();
                if (solrType.tokenizerable) {
                    tt = new com.alibaba.fastjson.JSONObject();
                    tt.put("key", entry.getKey());
                    tt.put("value", entry.getKey());
                    tokens.add(tt);
                }
            }
            f.put("tokensType", tokens);
        }
        types.add(f);
    }
    for (Map.Entry<String, SolrFieldsParser.SolrType> entry : this.types.entrySet()) {
        solrType = entry.getValue();
        if (!solrType.tokenizerable && !TokenizerType.isContain(entry.getKey())) {
            f = new com.alibaba.fastjson.JSONObject();
            f.put("name", entry.getKey());
            types.add(f);
        }
    }
    // schema.put("fieldtypes", types);
    return types;
}
Also used : VisualType(com.qlangtech.tis.runtime.module.misc.VisualType) SolrFieldsParser(com.qlangtech.tis.solrdao.SolrFieldsParser) ISearchEngineTokenizerType(com.qlangtech.tis.runtime.module.misc.ISearchEngineTokenizerType)

Aggregations

VisualType (com.qlangtech.tis.runtime.module.misc.VisualType)6 JSONArray (com.alibaba.fastjson.JSONArray)3 SolrFieldsParser (com.qlangtech.tis.solrdao.SolrFieldsParser)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ISearchEngineTokenizerType (com.qlangtech.tis.runtime.module.misc.ISearchEngineTokenizerType)2 TokenizerType (com.qlangtech.tis.runtime.module.misc.TokenizerType)1 ISchemaField (com.qlangtech.tis.solrdao.ISchemaField)1 SolrType (com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType)1 Map (java.util.Map)1