2011-08-19 70 views
0

考虑下面的CSV文件拆分超过一(1)场:我如何使用Solr的CSV导入

id,name,manu,cat,features,price,popularity,inStock,manufacturedate_dt,store 
SPF15,Hawaii Sunblock,P&G,lotion|medicine|ointment,15SPF|waterproof|kidsfriendly,8.99,8,true,2011-02-13T15:26:37Z,"35.0752,-97.032" 

当我运行此命令

curl 'http://localhost:8080/solr/update/csv?commit=true&f.features.split=true&f.features.separator=%7Cf.cat.split=true&f.cat.separator=%7C' --data-binary @input.csv -H 'Content-type:text/plain; charset=utf-8' 

只有功能是分而不是猫

<response> 

<lst name="responseHeader"> 
    <int name="status">0</int> 
    <int name="QTime">2</int> 
    <lst name="params"> 
    <str name="indent">on</str> 
    <str name="start">0</str> 
    <str name="q">ointment</str> 

    <str name="rows">10</str> 
    <str name="version">2.2</str> 
    </lst> 
</lst> 
<result name="response" numFound="1" start="0"> 
    <doc> 
    <arr name="cat"><str>lotion|medicine|ointment</str></arr> 
    <arr name="features"><str>15SPF</str><str>waterproof</str><str>kidsfriendly</str></arr> 

    <str name="id">SPF15</str> 
    <bool name="inStock">true</bool> 
    <str name="manu">P&amp;G</str> 
    <date name="manufacturedate_dt">2011-02-13T15:26:37Z</date> 
    <str name="name">Hawaii Sunblock</str> 
    <int name="popularity">8</int> 

    <float name="price">8.99</float> 
    <str name="store">35.0752,-97.032</str> 
    </doc> 
</result> 
</response> 

。当切换字段,特征和猫的顺序,

curl 'http://localhost:8080/solr/update/csv?commit=true&f.cat.split=true&f.cat.separator=%7Cf.features.split=true&f.features.separator=%7C' --data-binary @input.csv -H 'Content-type:text/plain; charset=utf-8' 

只有猫是分裂的,但不拥有

<response> 

<lst name="responseHeader"> 
    <int name="status">0</int> 
    <int name="QTime">2</int> 
    <lst name="params"> 
    <str name="indent">on</str> 
    <str name="start">0</str> 
    <str name="q">ointment</str> 

    <str name="rows">10</str> 
    <str name="version">2.2</str> 
    </lst> 
</lst> 
<result name="response" numFound="1" start="0"> 
    <doc> 
    <arr name="cat"><str>lotion</str><str>medicine</str><str>ointment</str></arr> 

    <arr name="features"><str>15SPF|waterproof|kidsfriendly</str></arr> 
    <str name="id">SPF15</str> 
    <bool name="inStock">true</bool> 
    <str name="manu">P&amp;G</str> 
    <date name="manufacturedate_dt">2011-02-13T15:26:37Z</date> 
    <str name="name">Hawaii Sunblock</str> 

    <int name="popularity">8</int> 
    <float name="price">8.99</float> 
    <str name="store">35.0752,-97.032</str> 
    </doc> 
</result> 
</response> 

我检查了各种文献和教程,没有在同一请求分割多个字段的例子,但没有理由为什么它应该工作。

有什么想法?

谢谢

回答

2

你缺少一个&。尝试:

curl 'http://localhost:8080/solr/update/csv?commit=true&f.features.split=true&f.features.separator=%7C&f.cat.split=true&f.cat.separator=%7C' --data-binary @input.csv -H 'Content-type:text/plain; charset=utf-8' 

(请注意,我添加了一个&%7C