首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在mongoosastic中查询多索引、多类型?

如何在mongoosastic中查询多索引、多类型?
EN

Stack Overflow用户
提问于 2016-05-12 22:12:07
回答 1查看 414关注 0票数 0

我正在尝试查询具有多个索引和类型的多个表,但在mongoosastic中没有关于多索引、多类型查询的文档。

引用这个doc,尝试做同样的事情,但是使用mongoosastic查询。

EN

回答 1

Stack Overflow用户

发布于 2016-06-09 19:55:21

我也有同样的问题。请执行以下操作以使其正常工作。

确保删除了索引:

邮递员DELETE请求示例:http://127.0.0.1:9200/{your_name}

然后在节点JS中创建如下映射:

代码语言:javascript
复制
var schema = new Schema({
    product_name: String,
    description: {
        type: String,
        es_type: 'multi_field',
        es_fields: {
            multi_field: { type: 'string', index: 'analyzed' },
            untouched: { type: 'string', index: 'not_analyzed' }
        }
    }
});

最后,您可以像这样查询:

代码语言:javascript
复制
{
"query" : {
    "constant_score" : {
        "filter" : {
            "term" : {
                "description.multi_field" : "nog een testje"
            }
        }
    }
}}// to use other field, change the . after description
{
"query" : {
    "constant_score" : {
        "filter" : {
            "term" : {
                "description.untouched" : "nog een testje"
            }
        }
    }
}

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37189532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档