Search in sources :

Example 1 with ISearchEngineTokenizerType

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

the class ESSchema method serialTypes.

@Override
public JSONArray serialTypes() {
    JSONArray types = new JSONArray();
    com.alibaba.fastjson.JSONObject f = null;
    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 : EsTokenizerType.visualTypeMap.entrySet()) {
        f = new com.alibaba.fastjson.JSONObject();
        f.put("name", t.getKey());
        f.put("split", t.getValue().isSplit());
        tokens = new 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);
    }
    // schema.put("fieldtypes", types);
    return types;
}
Also used : VisualType(com.qlangtech.tis.runtime.module.misc.VisualType) JSONArray(com.alibaba.fastjson.JSONArray) SolrFieldsParser(com.qlangtech.tis.solrdao.SolrFieldsParser) ISearchEngineTokenizerType(com.qlangtech.tis.runtime.module.misc.ISearchEngineTokenizerType) Map(java.util.Map)

Example 2 with ISearchEngineTokenizerType

use of com.qlangtech.tis.runtime.module.misc.ISearchEngineTokenizerType 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

ISearchEngineTokenizerType (com.qlangtech.tis.runtime.module.misc.ISearchEngineTokenizerType)2 VisualType (com.qlangtech.tis.runtime.module.misc.VisualType)2 SolrFieldsParser (com.qlangtech.tis.solrdao.SolrFieldsParser)2 JSONArray (com.alibaba.fastjson.JSONArray)1 Map (java.util.Map)1