【问题标题】:Mongo data index on SolrCloudSolrCloud 上的 Mongo 数据索引
【发布时间】:2018-05-07 16:50:01
【问题描述】:

我正在尝试使用 mongo-connector 将 MongoDB 集合索引到 Solr 以实现我想要实现的搜索功能。如果我在 mongo 中的集合具有非常嵌套的 JSON 结构,我可以在 Solr 上对其进行索引吗?如果我们要索引下面显示的 json,Solr 中的模式文件会是什么样子?

"profile": {
   "id": "1234"
   "lastName": "Smith"
   "firstname" : "Daniel"
   "emails": {   
      "work": {
           "emailAddress": "abc@gmail.com", 
           "type": "work",          

       },

       "personal": {  
            "emailAddress": "nml@gmail.com", 
            "type": "personal",          

       }
    },
   "phones": {   
       "home": {
            "phoneNumber": "212345",     
        },
       "work": {
               "phoneNumber": "567899",   
        },
         "cell": {
               "phoneNumber": "112456",    
        }      
    }
}

【问题讨论】:

    标签: java mongodb solr solrj solrcloud


    【解决方案1】:

    mongo connector automagically flattens documents,因此字段名称为:

    "emails.work.emailAddress": "abc@gmail.com"
    

    .. 等等。这允许您通过动态字段定义匹配名称,您可以在其中 give field names with wildcards to match multiple different names 到相同的字段定义:

    <dynamicField name="emails.*" type="string" indexed="true"  stored="true"/>
    

    .. 将以emails. 开头的每个字段名称作为字符串字段(只允许完全匹配)进行索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-01
      • 1970-01-01
      • 2021-05-13
      • 2012-03-24
      • 1970-01-01
      • 2015-05-21
      • 2013-09-29
      • 2017-03-14
      相关资源
      最近更新 更多