[英]Indexing json on Solr, it indexed as a List instead of as an item
我正在嘗試索引Solr中的JSON文件並且它可以工作,但我不明白為什么Solr將元素索引為數組而不是元素。
當我為示例json文件“books.json”建立索引時,它工作正常,但如果我索引另一個文件“items.json”,它會生成不同的輸出。
我在下面顯示:
Books.json
[{
"id" : "978-0641723445",
"cat" : ["book","hardcover"],
"name" : "The Lightning Thief",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 12.50,
"pages_i" : 384
}]
OUTPUT
{
"id": "978-0641723445",
"cat": [
"book",
"hardcover"
],
"name": "The Lightning Thief",
"author": "Rick Riordan",
"author_s": "Rick Riordan",
"series_t": "Percy Jackson and the Olympians",
"sequence_i": 1,
"genre_s": "fantasy",
"inStock": true,
"price": 12.5,
"price_c": "12.5,USD",
"pages_i": 384,
"_version_": 1457847842153431000
},
Items.json
[{
"title" : "Pruebas Carlos",
"id" : 14,
"desc" : "Probando como funciona el campo de descripciones"
}]
OUTPUT
{
"title": [
"Pruebas Carlos"
],
"id": "10",
"desc": [
"Probando como funciona el campo de descripciones"
],
"_version_": 1457849881416695800
},
我的架構 ,我只添加了我需要的新字段。
有人可以向我解釋如何在沒有[]的情況下索引元素嗎?
謝謝
您已將兩個字段(title,desc)都設置為多值,這就是為什么,如果它們只有一個值,請執行此操作:
<field name="desc" type="text_general" indexed="true" stored="true" multiValued="false"/>
<field name="title" type="text_general" indexed="true" stored=" true" multiValued="false"/>
簡而言之,這些字段被模式配置為數組,這就是為什么它們被編寫為響應的JSON數組。 即使他們的樣品中只有一個成員。
如果它們只是單值,則需要將它們配置為multiValued="false"
。
您擔心title
和desc
的字段被配置為multiValued="true"
,您可以在此multiValued="true"
摘錄中看到
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="desc" type="text_general" indexed="true" stored="true" multiValued="true"/>
如果您在架構中向上滾動一點(到第82行),您可以閱讀它代表的含義
multiValued:如果此字段可能包含每個文檔的多個值,則為true
您可以閱讀這些有用的內容以及多種來源的后果
看起來你有一個與嵌套Jsons相關的問題,你可以使用 -
(i)/ solr / update / json?commit = true?split = /&f = txt:/ **
(ii)使用索引處理程序 - https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.