2011-08-19 67 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