【问题标题】:How to query Multi-index, Multitype in mongoosastic?如何在 mongoosastic 中查询多索引、多类型?
【发布时间】:2016-09-15 15:33:07
【问题描述】:

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

请参考doc 尝试做同样的事情,但使用 mongoosastic 查询。

【问题讨论】:

    标签: node.js mongodb elasticsearch mongoosastic


    【解决方案1】:

    我遇到了同样的问题。请执行以下操作以使其正常工作。

    确保您删除了索引:

    通过邮递员的删除请求,例如:http://127.0.0.1:9200/{your_name}

    然后在节点JS中创建一个这样的映射:

    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' }
            }
        }
    });
    

    终于可以这样查询了:

    {
    "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"
                }
            }
        }
    }
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多