elasticsearch,Search,elasticsearch" /> elasticsearch,Search,elasticsearch" />

msearch中每个查询的不同源筛选

msearch中每个查询的不同源筛选,search,elasticsearch,Search,elasticsearch,向飞越者致意 我正在使用ElasticSearch2.0API。我有几个使用msearch一起执行的查询。我想为每个查询指定不同的_源筛选选项(就像_类型一样),但是这些选项似乎被忽略了(即没有筛选任何内容) 有什么想法吗 示例查询: elasticsearch.msearch({ index: 'some_index', body: [ { _type: 'type_a', _source_exclude: ['f

向飞越者致意

我正在使用ElasticSearch2.0API。我有几个使用msearch一起执行的查询。我想为每个查询指定不同的_源筛选选项(就像_类型一样),但是这些选项似乎被忽略了(即没有筛选任何内容)

有什么想法吗

示例查询:

elasticsearch.msearch({
    index: 'some_index',
    body: [
        {
            _type: 'type_a',
            _source_exclude: ['field_a', 'field_b'].join()
        },
        {query: {constant_score: {filter: {term: {field_c: valueA}}}}},
        {
            _type: 'type_b',
            _source_exclude: ['field_d', 'field_e'].join()
        },
        {query: {constant_score: {filter: {term: {field_f: valueB}}}}}
    ]
}, function msearch(err, results) { /* logic... */ });
查看文档,您应该这样做:

elasticsearch.msearch({
    index: 'some_index',
    body: [
        {
            _type: 'type_a',
            _sourceExclude: ['field_a', 'field_b']
        },
        {query: {constant_score: {filter: {term: {field_c: valueA}}}}},
        {
            _type: 'type_b',
            _sourceExclude: ['field_d', 'field_e']
        },
        {query: {constant_score: {filter: {term: {field_f: valueB}}}}}
    ]
}, function msearch(err, results) { /* logic... */ });

您能显示您发送的请求吗?请参见上面的示例查询。问题是_source _exclude不起作用。你的建议没有成功。你试过了吗?我的错,我已经解决了这个问题,很抱歉,请再试一次。