大佬教程收集整理的这篇文章主要介绍了将文档从AngularJS发布到SOLR 4,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
架构快速概述:
SOLR和AngularJS应用程序都在我的Mac上运行.
SOLR使用默认的jetty实例,Angular应用程序在WebStorm IDE的服务器内运行. CORS已启用,包括GET,OPTIONs.
更新工作时:
>使用SOLR的仪表板
>使用命令行(示例)
$curl http:// localhost:8983 / solr / mrm_assay / update -H’Content-type:application / json’-d'[{
“keep_in_assay”{“set”:“N”,
“detected_endog”:“N”,
“problems_w_is”:“删除的b / c需要添加后绿洲”,
“onc_std_set”:“set1”,
“fraction_id”:“7”,
“onclistgene”:“UBL3”,
“genEID”:“UBL3_IS6”,
“taxonid”:“9606”,
“肽”:“SSNVPADMINLR”,
“degen_human”:“1”,
“gene_degeneracy”:“1”,
“percnt_id”:“66.7”,
“uuid”:“6d20eb03-d3ee-4eb2-bc16-27cfaabab989”
}]’
我的Angular控制器代码如下所示:
assayControllers.controller(‘AssayupdateController’,[‘$scope’,’$http’,
@R_848_3816@($scope,$http){
$scope.processForm = function(){
的console.log($scope.assay);
$http({
方法: ‘POST’,
网址: ‘http://本地主机:8983 / Solr的/ mrm_assay /更新’,
数据:$scope.assay,
标题:{‘Content-Type’:’application / json’}
})
.success(function(data,status,headers){
的console.log(data.@R_616_8798@gE);
})
.error(function(data,headers,config){
的console.log(状态);
});
};
}
]);
数据从表单中成功发送,因为我可以在控制台上看到它(虽然JSON对象没有打包在一个数组中,SOLR似乎期望…我还尝试将JSON格式的数据推送到数组并POST但没有运气)
我感谢您的帮助 – 即使只是为了指导我的故障排除!
I.在SOLRsolr-4.7.0 / example / solr-webapp / webapp / WEB-INF / web.xml附带的jetty服务器上配置CORS
注意:CrossOriginFilter有一个参数chainPreflight,默认情况下设置为true.这需要设置为false.这是CORS转发POST而不是SOLTIONS的关键.此外,订单很重要!
<filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <init-param> <param-name>allowedOrigins</param-name> <param-value>http://localhost*</param-value> </init-param> <init-param> <param-name>allowedMethods</param-name> <param-value>GET,OPTIONS</param-value> </init-param> <init-param> <param-name>allowedHeaders</param-name> <param-value>origin,options,authorization,x-requested-with</param-value> </init-param> <init-param> <param-name>supportsCredentials</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>chainPreflight</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
II. SOLR期望以数组格式的有效载荷,因此您需要将Angular对象推入一个.基本上,$scope.data变为[$scope.data]
assayControllers.controller('AssayupdateController',['$scope','$http','$LOCATIOn',function($scope,$http,$LOCATIOn){ $scope.processForm = function(){ $http.post("http://localhost:8983/solr/mrm_assay/update?commit=true",[$scope.assay]) .success(function(data,headers){ console.log(data.@R_616_8798@gE); $LOCATIOn.path("/assays") }) .error(function(data,config){ console.log(status); }); }; } ]);
III. SOLR文档包含可能导致POST出现“冲突”错误的版本字段.这是由于我无法追踪的缓存问题(卷曲显示当前值但浏览器有旧版;甚至强制刷新).无论如何,这对SOLR来说比我更有用,所以最好的办法是不要首先将它归还给客户.我不认为字段排除是一个选项,因此我将所有要在solrconfig.xml中返回的字段列入白名单
<!-- A request handler that returns indented JSON by default --> <requestHandler name="/query" class="solr.SearchHandler"> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="wt">json</str> <str name="indent">true</str> <str name="df">text</str> <str name="fl">uuid,keep_in_assay,detected_endog,problems_w_is,onc_std_set,fraction_id,detected_by_orbi_experiments,onclistgene,genEID,taxonid,peptide,\ degen_human,degen_mouse,gene_degeneracy,department,protein_ac,pepid,protid,percnt_id,peptide_ordered</str>
现在该应用程序就像一个魅力!
以上是大佬教程为你收集整理的将文档从AngularJS发布到SOLR 4全部内容,希望文章能够帮你解决将文档从AngularJS发布到SOLR 4所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。