mirror of https://github.com/apache/lucene.git
SOLR-7782 Allow non-JSON and JSON array uploads
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2cc7d08819
commit
d821ea9fd2
|
@ -85,35 +85,43 @@ solrAdminApp.controller('DocumentsController',
|
|||
|
||||
if ($scope.type == "json" || $scope.type == "wizard") {
|
||||
postData = "[" + $scope.document + "]";
|
||||
contentType = "application/json";
|
||||
contentType = "json";
|
||||
} else if ($scope.type == "csv") {
|
||||
postData = $scope.document;
|
||||
contentType = "application/csv";
|
||||
contentType = "csv";
|
||||
} else if ($scope.type == "xml") {
|
||||
postData = "<add>" + $scope.document + "</add>";
|
||||
contentType = "text/xml";
|
||||
contentType = "xml";
|
||||
} else if ($scope.type == "upload") {
|
||||
doingFileUpload = true;
|
||||
params.raw = $scope.literalParams;
|
||||
} else if ($scope.type == "solr") {
|
||||
postData = $scope.document;
|
||||
if (postData[0] == "<") {
|
||||
contentType = "text/xml";
|
||||
} else if (postData[0] == "{") {
|
||||
contentType = "application/json";
|
||||
contentType = "xml";
|
||||
} else if (postData[0] == "{" || postData[0] == '[') {
|
||||
contentType = "json";
|
||||
} else {
|
||||
alert("Cannot identify content type")
|
||||
}
|
||||
}
|
||||
if (!doingFileUpload) {
|
||||
Update.post(params, postData).then(function (success) {
|
||||
$scope.responseStatus = "success";
|
||||
delete success.$promise;
|
||||
delete success.$resolved;
|
||||
$scope.response = JSON.stringify(success, null, ' ');
|
||||
}).fail(function (failure) {
|
||||
var callback = function (success) {
|
||||
$scope.responseStatus = "success";
|
||||
delete success.$promise;
|
||||
delete success.$resolved;
|
||||
$scope.response = JSON.stringify(success, null, ' ');
|
||||
};
|
||||
var failure = function (failure) {
|
||||
$scope.responseStatus = failure;
|
||||
});
|
||||
};
|
||||
if (contentType == "json") {
|
||||
Update.postJson(params, postData, callack, failure);
|
||||
} else if (contentType == "xml") {
|
||||
Update.postXml(params, postData, callback, failure);
|
||||
} else if (contentType == "csv") {
|
||||
Update.postCsv(params, postData, callback, failure);
|
||||
}
|
||||
} else {
|
||||
var file = $scope.fileUpload;
|
||||
console.log('file is ' + JSON.stringify(file));
|
||||
|
|
|
@ -78,10 +78,13 @@ solrAdminServices.factory('System',
|
|||
}])
|
||||
.factory('Update',
|
||||
['$resource', function($resource) {
|
||||
return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'/update'}, {
|
||||
return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'update'}, {
|
||||
"optimize": {params: { optimize: "true"}},
|
||||
"commit": {params: {commit: "true"}},
|
||||
"post": {method: "POST", params: {handler: '@handler'}}
|
||||
"post": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
|
||||
"postJson": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
|
||||
"postXml": {headers: {'Content-type': 'text/xml'}, method: "POST", params: {handler: '@handler'}},
|
||||
"postCsv": {headers: {'Content-type': 'application/csv'}, method: "POST", params: {handler: '@handler'}}
|
||||
});
|
||||
}])
|
||||
.service('FileUpload', function ($http) {
|
||||
|
|
Loading…
Reference in New Issue