【问题标题】:How to use solr index different type of data?如何使用 solr 索引不同类型的数据?
【发布时间】:2017-04-12 21:36:50
【问题描述】:

我使用 solr 来索引 json 数据。代码如下:

    curl http://localhost:8983/solr/demo/update -d '
[
 {"id"         : "book2",
  "cat_s"      : "fantasy" ,
  "pubyear_i"  :  2010 ,
  "ISBN_s"     : "978-0-7653-2635-5" 
 }
]'

现在,我想索引 CSV、XML 或其他类型的数据,我该怎么做?

【问题讨论】:

  • 你能在这里发布 solr 架构吗?

标签: solr


【解决方案1】:

在请求Header中添加Content-Type参数。

内容类型映射:

--------------------------------
|  Type      |  Value           |
-------------+-------------------
|  xml       | application/xml  |
|------------+------------------|
|  csv       | application/csv  |
|------------+------------------|
|  json      | application/json |
--------------------------------

xml 示例:

curl -H 'Content-Type: application/xml' http://localhost:8983/solr/demo/update -d '
<add>
   <doc>
      <field name="id">book2</field>
      <field name="cat_s">fantasy</field>
      <field name="pubyear_i">2010</field>
      <field name="ISBN_s">978-0-7653-2635-5</field>
   </doc>
</add>'

更多:https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers

【讨论】:

  • 您好兄弟,对于 xml 示例,它响应 Illegal processing instruction target ("xml"); xml(不区分大小写)由规范保留。在 [row,col {unknown-source}]:[2,5]400
  • @zechengzhao 更新答案,
  • @zechengzhao 如果答案正确,请标记它。
猜你喜欢
  • 2010-11-03
  • 2019-07-09
  • 2011-03-03
  • 1970-01-01
  • 2012-01-09
  • 2014-10-22
  • 1970-01-01
  • 2015-12-23
  • 2014-10-25
相关资源
最近更新 更多