You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Noble Paul (JIRA)" <ji...@apache.org> on 2015/03/05 21:01:39 UTC
[jira] [Comment Edited] (SOLR-6304) Transforming and Indexing
custom JSON data
[ https://issues.apache.org/jira/browse/SOLR-6304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14349389#comment-14349389 ]
Noble Paul edited comment on SOLR-6304 at 3/5/15 8:01 PM:
----------------------------------------------------------
Sorry I didn't mean to imply that anything was wrong with the example... I wanted to know if it was possible to send multiple JSON documents in a single request, like this:
{noformat}
curl 'http://localhost:8983/solr/collection1/update/json/docs'
'?split=/exams'
'&f=first:/first'
'&f=last:/last'
'&f=grade:/grade'
'&f=subject:/exams/subject'
'&f=test:/exams/test'
'&f=marks:/exams/marks'
-H 'Content-type:application/json' -d '
{
"first": "John",
"last": "Doe",
"grade": 8,
"exams": [
{"subject": "Maths", "test" : "term1", "marks":90},
{"subject": "Biology", "test" : "term1", "marks":86}
]
}
{
"first": "Bob",
"last": "Smith",
"grade": 7,
"exams": [
{"subject": "Maths", "test" : "term1", "marks":95},
{"subject": "Biology", "test" : "term1", "marks":92}
]
}
'
{noformat}
And then get 4 documents added to solr:
john, doe, maths...
john, doe, biology...
bob, smith, maths...
bob, smith, biology...
An example of the code I was trying to write is here:
https://github.com/bbende/solrj-custom-json-update/blob/master/src/test/java/org/apache/solr/IndexJSONTest.java
testAddMultipleJsonDocsWithContentStreamUpdateRequest
was (Author: bende):
Sorry I didn't mean to imply that anything was wrong with the example... I wanted to know if it was possible to send multiple JSON documents in a single request, like this:
curl 'http://localhost:8983/solr/collection1/update/json/docs'
'?split=/exams'
'&f=first:/first'
'&f=last:/last'
'&f=grade:/grade'
'&f=subject:/exams/subject'
'&f=test:/exams/test'
'&f=marks:/exams/marks'
-H 'Content-type:application/json' -d '
{
"first": "John",
"last": "Doe",
"grade": 8,
"exams": [
{"subject": "Maths", "test" : "term1", "marks":90},
{"subject": "Biology", "test" : "term1", "marks":86}
]
}
{
"first": "Bob",
"last": "Smith",
"grade": 7,
"exams": [
{"subject": "Maths", "test" : "term1", "marks":95},
{"subject": "Biology", "test" : "term1", "marks":92}
]
}
'
And then get 4 documents added to solr:
john, doe, maths...
john, doe, biology...
bob, smith, maths...
bob, smith, biology...
An example of the code I was trying to write is here:
https://github.com/bbende/solrj-custom-json-update/blob/master/src/test/java/org/apache/solr/IndexJSONTest.java
testAddMultipleJsonDocsWithContentStreamUpdateRequest
> Transforming and Indexing custom JSON data
> ------------------------------------------
>
> Key: SOLR-6304
> URL: https://issues.apache.org/jira/browse/SOLR-6304
> Project: Solr
> Issue Type: Improvement
> Reporter: Noble Paul
> Assignee: Noble Paul
> Fix For: 4.10, Trunk
>
> Attachments: SOLR-6304.patch, SOLR-6304.patch
>
>
> example
> {noformat}
> curl localhost:8983/update/json/docs?split=/batters/batter&f=recipeId:/id&f=recipeType:/type&f=id:/batters/batter/id&f=type:/batters/batter/type -d '
> {
> "id": "0001",
> "type": "donut",
> "name": "Cake",
> "ppu": 0.55,
> "batters": {
> "batter":
> [
> { "id": "1001", "type": "Regular" },
> { "id": "1002", "type": "Chocolate" },
> { "id": "1003", "type": "Blueberry" },
> { "id": "1004", "type": "Devil's Food" }
> ]
> }
> }'
> {noformat}
> should produce the following output docs
> {noformat}
> { "recipeId":"001", "recipeType":"donut", "id":"1001", "type":"Regular" }
> { "recipeId":"001", "recipeType":"donut", "id":"1002", "type":"Chocolate" }
> { "recipeId":"001", "recipeType":"donut", "id":"1003", "type":"Blueberry" }
> { "recipeId":"001", "recipeType":"donut", "id":"1004", "type":"Devil's food" }
> {noformat}
> the split param is the element in the tree where it should be split into multiple docs. The 'f' are field name mappings
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org