Marklogic 400错误请求

Marklogic 400错误请求,marklogic,Marklogic,我试图在RESTURI中使用StructuredQuery,如文档所示 当我使用Chrome中的Postman并请求查询URI时: http://IPADDRESS:PORT/v1/search?structuredQuery={"query":{"or-query":{"queries":[{"and-query":{"queries":[ {"word-constraint-query":{"constraint-name":"bio","text":["product"]}}, {"val


我试图在RESTURI中使用StructuredQuery,如文档所示
当我使用Chrome中的Postman并请求查询URI时:

http://IPADDRESS:PORT/v1/search?structuredQuery={"query":{"or-query":{"queries":[{"and-query":{"queries":[ {"word-constraint-query":{"constraint-name":"bio","text":["product"]}}, {"value-constraint-query":{"constraint-name":"company","text":["MarkLogic"]}} ]}}, {"and-query":{"queries":[ {"element-constraint-query":{"constraint-name":"spoken","and-query": {"queries":[{"term-query":{"text":["fie"]}}]} }}, {"word-constraint-query":{"constraint-name":"stagedir","text":["fall"]}}, {"value-constraint-query":{"constraint-name":"person","text":["GRUMIO"]}} ]}}, {"and-query":{"queries":[ {"properties-query":{"term-query":{"text":["fish"]}}}, {"directory-query":{"uri":["/images/2012/02/27/"]},"infinite":true} ]}}, {"and-query":{"queries":[ {"collection-query":{"uri":["mlw2012"]}}, {"term-query":{"text":["fun"]}} ]}}]}}}
这是给我答复

现在,当我尝试在Java中实现这一点时,使用HttpClient它会给我400个错误请求错误,代码:

CredentialsProvider credsProvider = new BasicCredentialsProvider();
query="http://192.168.192.110:8013/v1/search?structuredQuery=%7B%22query%22%3A%7B%22or-query%22%3A%7B%22queries%22%3A%5B%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22word-constraint-query%22%3A%7B%22constraint-name%22%3A%22bio%22%2C%22text%22%3A%5B%22product%22%5D%7D%7D%2C%20%7B%22value-constraint-query%22%3A%7B%22constraint-name%22%3A%22company%22%2C%22text%22%3A%5B%22MarkLogic%22%5D%7D%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22element-constraint-query%22%3A%7B%22constraint-name%22%3A%22spoken%22%2C%22and-query%22%3A%20%7B%22queries%22%3A%5B%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fie%22%5D%7D%7D%5D%7D%20%7D%7D%2C%20%7B%22word-constraint-query%22%3A%7B%22constraint-name%22%3A%22stagedir%22%2C%22text%22%3A%5B%22fall%22%5D%7D%7D%2C%20%7B%22value-constraint-query%22%3A%7B%22constraint-name%22%3A%22person%22%2C%22text%22%3A%5B%22GRUMIO%22%5D%7D%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22properties-query%22%3A%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fish%22%5D%7D%7D%7D%2C%20%7B%22directory-query%22%3A%7B%22uri%22%3A%5B%22%2Fimages%2F2012%2F02%2F27%2F%22%5D%7D%2C%22infinite%22%3Atrue%7D%20%5D%7D%7D%2C%20%7B%22and-query%22%3A%7B%22queries%22%3A%5B%20%7B%22collection-query%22%3A%7B%22uri%22%3A%5B%22mlw2012%22%5D%7D%7D%2C%20%7B%22term-query%22%3A%7B%22text%22%3A%5B%22fun%22%5D%7D%7D%20%5D%7D%7D%5D%7D%7D%7D"
    credsProvider.setCredentials(new AuthScope(IpAddress, port), new UsernamePasswordCredentials(user, password));

    DefaultHttpClient client = new DefaultHttpClient();
    client.setCredentialsProvider(credsProvider);

    HttpGet get = new HttpGet(query);
    ResponseHandler<String> handler = new BasicResponseHandler();
    HttpResponse resp = client.execute(get);
我错过了什么

提前感谢,

Prithvi.

如果您打印出错误响应的主体,那么应该会提供更多信息


你说,你可能想考虑使用Apache HtpClient和Jersey客户端之上的java API来处理你的HTTP交互。

< P>你可以尝试使用<代码>搜索:在查询控制台中解析< /COD>。为了验证,您可以使用
search:parse
从查询文本构造结构化查询。您可能没有在选项节点中正确定义约束,这将使您有机会对其进行测试,并使用
search:check options
确认您的选项节点结构正确。您应该在REST服务上使用
/v1/config/query/(default |{name})
来安装与默认选项相同的选项节点,或者使用
选项
URL参数作为查询选项。通过这种方式,您可以确保您的约束、范围索引等都已建立,否则您将从REST接口获得“坏请求”响应

HTTP/1.1 400 Bad Request [Content-type: application/xml, Server: MarkLogic, Content-Length: 364, Connection: Keep-Alive, Keep-Alive: timeout=5]