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

标签 solr configuration schema solr4

如何在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将是什么:


人字串
地址

城市字符串
邮政编码字符串

最佳答案

我知道这是一个古老的问题,但我遇到了类似的问题。为您修改我的解决方案,您需要添加到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
    }
}

关于solr - 如何在Solr中编写嵌套的schema.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22395683/

相关文章:

java - 动态生成 java 源代码(没有 xjc)

ruby-on-rails - Sunspot -- Boost 记录出现在文本早期的匹配项

Tomcat 工作但 Solr 不工作

ios - 无法在 Visual Studio 2013 for Xamarin Projects 中从 iPhone 切换到 iPhoneSimulator

c# - 在运行时在 c# 应用程序中添加用户设置

sql-server - 保持两个数据库模式同步的最佳方法是什么?

ruby-on-rails - 使用 Solr 搜索按相关性对结果进行排序

lucene - 在 Lucene Solr 中检索每个关键字/字段匹配位置——可能吗?

java - 将基于 Spring XML 的配置转换为基于 Java 的配置

schema - XSD:如何重新定义 simpleType 的数据类型,例如。从 xs:string 到 xs:integer