2014-03-14 56 views
11

如何寫嵌套schema.xml中Solr中如何在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:

  • 人串
  • 地址
    • 城市串
    • 郵編串

回答

5

我知道這是一個老問題,但我遇到了類似的問題。修改我爲你的解決方案,你需要添加到您的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 
    } 
} 
+3

如果多值是真的會不會是一個地址列表? – aaa90210