【问题标题】:MongoDB Atlas Search Definition JSON - String arraysMongoDB Atlas 搜索定义 JSON - 字符串数组
【发布时间】:2021-08-19 06:18:04
【问题描述】:

我的 MongoDB Atlas 的集合中有一个这样的对象:

{
  "outer" : {
     "tags" : [
        "astring",
        "another string",
        ...
     ],
     ...
  }
  ...
}

现在我希望在数组 outer.tags 上建立索引。我做了这样的索引定义:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "outer": {
        "dynamic": false,
        "fields": {
          "tags": {
            "dynamic": true
          }
        }
        ...
      }
      ...
    }
  }
}

但我仍然无法在标签内搜索,我应该如何更改定义以便能够这样做?

【问题讨论】:

  • outer 应该是 type document
  • 是的,它存在于实际放入 Mongo Atlas 控制台的内容中(因此...),但它仍然没有帮助。没关系,感谢您的努力,我已修复它,我将作为自我回答发布

标签: mongodb mongodb-atlas mongodb-atlas-search


【解决方案1】:

简单地解决了这个问题:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "outer": {
        "dynamic": false,
        "fields": {
          "tags": {
            "analyzer": "lucene.simple",
            "searchAnalyzer": "lucene.simple",
            "type": "string"
          }
        }
        ...
      }
      ...
    }
  }
}

【讨论】:

    猜你喜欢
    • 2017-09-18
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    • 1970-01-01
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多