How to write nested schema.xml in solr?

喜欢而已 提交于 2019-12-03 15:23:54

问题


How to write nested schema.xml in solr

The document in schema.xml says

<!-- 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

Which can be used in

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

What will be schema.xml for nesting the following items:

  • Person string
  • Address
    • city string
    • postcode string

回答1:


I know this is an old question, but I ran into a similar issue. Modifying my solution for yours, the fields you need to add to your schema.xml are as follows:

 <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" />

Then when you run it you should be able to add the following JSON to your Solr instance and see the matching output in the query:

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


来源:https://stackoverflow.com/questions/22395683/how-to-write-nested-schema-xml-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!