【问题标题】:How to write nested schema.xml in solr?如何在 solr 中编写嵌套的 schema.xml?
【发布时间】:2014-04-19 04:39:51
【问题描述】:

如何在 solr 中编写嵌套的 schema.xml

schema.xml 中的文档说

<!-- points to the root document of a block of nested documents. Required for nested
document support, may be removed otherwise
-->
<field name="_root_" type="string" indexed="true" stored="false"/>

http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml?view=markup

可以用在

https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-BlockJoinQueryParsers

用于嵌套以下项目的 schema.xml 是什么:

  • 人字串
  • 地址
    • 城市字符串
    • 邮政编码字符串

【问题讨论】:

    标签: solr configuration schema solr4


    【解决方案1】:

    我知道这是一个老问题,但我遇到了类似的问题。为您修改我的解决方案,您需要添加到您的 schema.xml 的字段如下:

     <field name="person" type="string" indexed="true" stored="true" />
     <field name="address" type="string" indexed="true" stored="true" multiValued="true"/> 
     <field name="address.city" type="string" indexed="true" stored="true" />
     <field name="address.postcode" type="string" indexed="true" stored="true" />
    

    然后,当您运行它时,您应该能够将以下 JSON 添加到您的 Solr 实例并在查询中看到匹配的输出:

    {
      "person": "John Smith",
      "address": {
          "city": "San Diego",
          "postcode": 92093
        }
    }
    

    【讨论】:

    • 如果 multivalued 为真,它不是地址列表吗?
    • @aaa90210 是的,它会是,但这就是正确的。它应该有多个孩子。如果只有一个孩子,为什么还要有孩子的文档,只需展平孩子的json。类似于:address_city 和 address_postcode
    猜你喜欢
    • 2015-09-01
    • 2023-03-27
    • 2015-10-24
    • 1970-01-01
    • 1970-01-01
    • 2013-04-11
    • 2013-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多