Search View Structure

// 一个视图对应多个Content Indecies
let searchViewConfig = {
    name: 'Client View',
    description: 'This view is built for normal client.',
    status: published,
    // 组件布局结构
    layout: {
        top: [ { widgetId: 1 } ],
        left: [ { widgetId: 2 } ],
        right: [ { widgetId: 3 } ],
        bottom: [ { widgetId: 4 } ]
    },
    // 搜索操作输出项结构
    outputs: [
        {
            // 输出的内容
            searchIndexId: 1,
            willReturn: true,
            fields: [
                {
                    fieldName: 'age',
                    fieldType: 'integer',
                    willReturn: true,
                    type: 'static / dynamic', // static表示index中现有的字段,dynamic表示index中不存在的字段
                    esRule: {
                        // 无论text、keyword、boolean、int哪种数据类型,匹配“是否相等”时filter都用match。
                        match: {
                            age: {
                                query: 30
                            }
                        },
                        // 一般对于数字或日期数据类型,匹配范围时,filter使用range。
                        range: {
                            age: {
                                gte: 18,
                                lte: 60
                            }
                        }
                    }
                },
                {
                    fieldName: 'email',
                    fieldType: 'text',
                    willReturn: false,
                    type: 'static / dynamic', // static表示index中现有的字段,dynamic表示index中不存在的字段
                    esRule: {}
                }
            ]
        },
        {
            searchIndexId: 2,
            willReturn: false,
            fields: [
                {
                    fieldName: 'name',
                    fieldType: 'text',
                    willReturn: true,
                    type: 'static / dynamic', // static表示index中现有的字段,dynamic表示index中不存在的字段
                    esRule: {}
                },
                {
                    fieldName: 'industry',
                    fieldType: 'text',
                    willReturn: true,
                    type: 'static / dynamic', // static表示index中现有的字段,dynamic表示index中不存在的字段
                    esRule: {}
                }
            ]
        }
    ],
    // 组件搜索条件结构
    // 组件需要获取它可以关联的字段的列表
    widgets: [
        {
            // 这是一个关键字搜索栏,用于匹配Talent或Company的名字
            id: 1,
            widgetId: 1,
            name: 'SearchBar',
            config: {
                size: 'big'
            },
            // 该组件关联的ES字段,即用户的输入内容需要用哪些ES字段匹配
            linkedFields: [
                {
                    searchIndexId: 1,
                    fieldName: 'name',
                    esRule: {
                        "boost": 3,
                        "operator": "AND | OR"  // 后端查询默认使用”OR“,这里“AND”和“OR”大写
                    }
                },
                {
                    searchIndexId: 1,
                    fieldName: 'Company.name',
                    esRule: {}
                },
                {
                    searchIndexId: 2,
                    fieldName: 'name',
                    esRule: {}
                },
                {
                    searchIndexId: 2,
                    fieldName: 'Talent.name',
                    esRule: {}
                }
            ]
        },
        {
            // 这是一个范围选择器,用于指定Talent的年龄区间
            id: 2,
            widgetId: 2,
            name: 'RangeBar',
            config: {
                size: 'small'
            },
            linkedFields: [
                {
                    searchIndexId: 1,
                    fieldName: 'Talent.age',
                    esRule: {}
                }
            ]
        },
        {
            // 这是一个多项选择器,用于指定Talent或Company所在的城市
            id: 3,
            widgetId: 3,
            name: 'MultiSelect',
            config: {
                size: small
            },
            linkedFields: [
                {
                    searchIndexId: 1,
                    fieldName: 'city',
                    esRule: {}
                },
                {
                    searchIndexId: 2,
                    fieldName: 'city',
                    esRule: {}
                }
            ]
        },
        {
            // 这是一个自定义elasticsearch查询条件的输入栏
            id:4,
            widgetId: 99,
            name: 'qString',
            config: {
                size: small
            },
            linkedFields: [] // 该widget不支持关联字段
        }
    ]
};

results matching ""

    No results matching ""