【问题标题】:index a csv file solr - missing content stream索引 csv 文件 solr - 缺少内容流
【发布时间】:2013-04-10 07:17:54
【问题描述】:
Error is as follows :
[root@hdqsltest1 garyTestDocs]# curl http://localhost:8983/solr/update/csv? literal.id=book2&commit --data-binary @sample.csv -H 'Content-type:text/plain; charset=utf- 8'
[1] 16541
bash: commit: command not found

响应看起来像这样 -

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 missing content stream</title>
</head>
<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /solr/update/csv. Reason:
<pre>    missing content stream</pre></p><hr /><i><small>Powered by Jetty://</small>     </i><br/>                                                
<br/>                                                
<br/>                                                
</body>
</html>                                                

sample.csv 输入 -

 module,meets,question,response
 General Questions,,"Please provide us a detailed company background","We are great"  

schema.xml -

 <field name="module" type="text" indexed="true" stored="true" />
 <field name="meets" type="text" indexed="true" stored="true" />
 <field name="question" type="text" indexed="true" stored="true" />
 <field name="response" type="text" indexed="true" stored="true" />

solrconfig.xml

 <!-- CSV update handler, loaded on demand -->

  <requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy">
       <lst name="defaults"> 
             <str name="separator">,</str>
             <str name="header">true</str>
             <str name="encapsulator">"</str>
        </lst> 
   </requestHandler>

另一个示例.csv

   module,meets,question,response
   General Questions,,"Please provide us a detailed company background","Yes"

我已启用远程流式传输。我的查询是

   curl http://localhost:8983/solr/update/csv?literal.id=book12&commit=true --data-binary @sample.csv -H 'Content-type:text/plain; charset=utf-8' 

那么我做错了什么。请指导。

solr 版本 = 3.6.2。

索引的全部意义在于能够查询字段?我还想知道是否可以提取 csv 文件以将其文本放置在各个字段中,我知道它将 csv 文件的文本放置在内容字段中。有关更新/提取的任何建议?我在这里问了2个qns。谢谢。

【问题讨论】:

    标签: solr


    【解决方案1】:

    其实刚刚解决了这个查询的问题

    curl http://localhost.com:8983/solr/update/csv?commit=true --data-binary @sample.csv -H 'Content-type:text/plain;字符集=utf-8'

    但在执行此查询之前,我不断收到 required id field 错误,我会转到我的查询并提及 literal.id=ABC1 (一些唯一的随机 id),然后我仍然遇到相同的错误。所以我去了我的 schema.xml 并删除了字段 id 所需的属性并重新启动了 solr 并运行了上面的查询,但仍然出现错误。所以当我在我的 sample.csv 中创建一个 id 列并将其编入索引时,解决方案就出现了。我其实不喜欢这样!但它奏效了。

    【讨论】:

      【解决方案2】:

      如果您启用了远程流式传输,则需要在请求中指定内容类型和文件作为查询参数。

      这是来自Solr Wiki的示例

      具体来说,您的查询字符串看起来有点像这样 -

      curl http://localhost:8983/solr/update/csv?stream.file=<remote path>/sample.csv&stream.contentType=text/plain;charset=utf-8
      

      请注意,使用远程流式传输时,您需要确保 Solr 实例可以访问文件的位置。

      【讨论】:

      • 我继续得到同样的错误!什么是内容流?我只是不明白出了什么问题?我能够索引一个示例 csv 文件,例如 id、作者、标题(第 1 行)1、sanjay、ABC(第 2 行)、2、Ajay、XYZ(第 3 行)。我能够索引这个文件,但它不会索引上面提到的带有空格和引号的 sample.csv 文件。
      • 哦 - 我错过了引号部分 - 您必须在索引时转义引号。这是一个特殊的字符。 These special characters需要在前面加一个``字符来转义。
      • 你能澄清一下吗?我也在思考你是否看到我上面的 sample.csv 文件有空格?这会是个问题吗?
      【解决方案3】:

      首先更改目录以找到您的 csv 文件,

      cd <file_path>
      

      curl http://localhost:8983/solr/update/csv?commit=true --data-binary @sample.csv -H 'Content-type:text/plain; charset=utf-8'
      

      从终端运行此脚本。我希望能解决你的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-11-12
        • 2015-07-23
        • 1970-01-01
        • 1970-01-01
        • 2023-04-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多