Azure的兵网络搜索失败,搜索查询 [英] Azure Bing Web search fails with Query search
本文介绍了Azure的兵网络搜索失败,搜索查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Odata4j。当我尝试执行与我的查询简单的Web搜索,在code的最后一行得到以下exeception:
PS:如果你发现这个helpful.Thanks请voteup
了java.lang.RuntimeException:预期状态OK,发现错误的请求。服务器响应:
参数:查询的类型为String不
在org.odata4j.jersey.consumer.ODataJerseyClient.doRequest(ODataJerseyClient.java:165)
这是我的code:
ODataConsumer消费= ODataConsumers
.newBuilder(https://api.datamarket.azure.com/Bing/Search/v1/)
.setClientBehaviors(OClientBehaviors.basicAuth(accountKey,我的帐户在此关键))
。建立();
的System.out.println(consumer.getServiceRootUri()+ consumer.toString()); OQueryRequest< OEntity> 。oQueryRequest = consumer.getEntities(网络)的自定义(查询,搜索文本标准);
的System.out.println(oRequest+ oQueryRequest); 枚举< OEntity>实体= oQueryRequest.execute();
解决方案
不多到Java,但我刚刚拿到了与Node.js的实施同样的错误,问题是,我忘了加单引号周围的查询。它应该是这样的:
...&安培;查询='计算器'
所以URL编码之后,我们有这样的:
...&安培;查询=%27stackoverflow 27%
在为我工作最少。
I am using the Odata4j. When i try to execute for simple Web search with my query, getting following exeception at last line of the code:
PS: Please voteup if you find this helpful.Thanks
java.lang.RuntimeException: Expected status OK, found Bad Request. Server response:
Parameter: Query is not of type String
at org.odata4j.jersey.consumer.ODataJerseyClient.doRequest(ODataJerseyClient.java:165)
This is my code:
ODataConsumer consumer = ODataConsumers
.newBuilder("https://api.datamarket.azure.com/Bing/Search/v1/")
.setClientBehaviors(OClientBehaviors.basicAuth("accountKey", "My account key here"))
.build();
System.out.println(consumer.getServiceRootUri()+consumer.toString());
OQueryRequest<OEntity> oQueryRequest = consumer.getEntities("Web").custom("Query", "Search text criteria");
System.out.println("oRequest"+oQueryRequest);
Enumerable<OEntity> entities = oQueryRequest.execute();
解决方案
Not much into Java, but I've just got the same error with the implementation for Node.js, and the problem was that I forgot to add single quotes around the query. It should be something like:
...&Query='stackoverflow'
so after the URL encoding we have something like:
...&Query=%27stackoverflow%27
At least that worked for me.
这篇关于Azure的兵网络搜索失败,搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文