Hi, Puneet: Your request doesn't specify your options. If you haven't installed your options as the default, you should install your options under another name and refer to them with the options URI parameter or POST your options as part of the request:
http://docs.marklogic.com/guide/rest-dev/search#id_83871 If you POST query options, it would be better to specify the sort order in the options instead of parsing them from the string. You should consider whether you can run an unfiltered search (as with the default options). Hoping that helps, Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of Yinyan guy [[email protected]] Sent: Monday, May 11, 2015 2:40 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Search API : defining a new operator Hi Eric, Thank You for the information. I have chosen the Search operator option (http://docs.marklogic.com/guide/search-dev/query-options#) and following is my xml file <search:options xmlns:search="http://marklogic.com/appservices/search"> <search:operator name="sort"> <search:state name="relevance"> <search:sort-order> <search:score/> </search:sort-order> </search:state> <search:state name="city"> <search:sort-order direction="descending" type="xs:string"> <search:element ns="my-ns" name="city"/> </search:sort-order> <search:sort-order> <search:score/> </search:sort-order> </search:state> </search:operator> </search:options> I am using the following url to search http://localhost:8040/v1/search?q=red%20sort:city But I am not able retrieve any result(without sort:city displays the result) is this the right way to use the search option? regards, Puneet ________________________________ From: [email protected] To: [email protected] Date: Sun, 10 May 2015 14:11:20 +0000 Subject: Re: [MarkLogic Dev General] Search API : defining a new operator Hi, Puneet: The search:query element can not contain a search:operator child element. Only the search:options element can contain a search:operator child element. The valid options elements are described here: http://docs.marklogic.com/guide/rest-dev/appendixb The valid query elements are described here: http://docs.marklogic.com/guide/search-dev/structured-query#id_59265 The REST API supports sending both query and options in a single request: http://docs.marklogic.com/guide/rest-dev/search#id_69918 Instead of putting the sort order in a string (which has to be parsed), you might want to specify it directly in the options with the sort-order element: http://docs.marklogic.com/guide/rest-dev/appendixb#id_33716 Hoping that helps, Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of Yinyan guy [[email protected]] Sent: Saturday, May 09, 2015 10:34 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Search API : defining a new operator Hi Joe, Thanks for your response. I realized I was not on the right track but I have slightly improvised . Now I am configuring 2 search option First one defining the sort operator using following XML <?xml version="1.0"?> <options xmlns="http://marklogic.com/appservices/search"> <operator name="sort"> <state name="relevance"> <sort-order> <score/> </sort-order> </state> <state name="postedon"> <sort-order direction="descending" type="xs:date"> <json-property>postedon</json-property> </sort-order> <sort-order> <score/> </sort-order> </state> </operator> </options> This one works without the error. Now when I am trying to define the state using a separate XML as follows <?xml version="1.0"?> <query xmlns:search="http://marklogic.com/appservices/search"> <operator-state> <operator-name>sort</operator-name> <state-name>postedon</state-name> </operator-state> </query> I am getting the following error {"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: Unexpected Payload: \t\t\tsort\t\tpostedon\t"}} > User-Agent: curl/7.30.0 > Host: localhost:8040 > Accept: */* > Content-type: application/xml > Content-Length: 194 > * upload completely sent off: 194 out of 194 bytes < HTTP/1.1 400 Bad Request < Content-type: application/json; charset=UTF-8 The data that I have is in JSON form and has postedon as date of the type "2015-04-11", Now the error seems to be about the structure but I am not able to understand. regards, Puneet ________________________________ From: [email protected] To: [email protected] Date: Sun, 10 May 2015 05:05:54 +0000 Subject: Re: [MarkLogic Dev General] Search API : defining a new operator Hi Puneet, What's the HTTP status code from your search request? Are you getting an error in the response body, or simply a valid response with no results? (If you're getting an error, you can find more details in the MarkLogic error log at http://localhost:8001/get-error-log.xqy?filename=ErrorLog.txt) Thanks. -jb From: Yinyan guy <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Saturday, May 9, 2015 at 9:12 PM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Search API : defining a new operator Hi, I was able to define the operator with following XML <options xmlns="http://marklogic.com/appservices/search"<http://marklogic.com/appservices/search%22>> <operator name="sort"> <state name="postedon"> <sort-order type="xs:date" direction="ascending"> <json-property>postedon</json-property> </sort-order> </state> </operator> </options> I can confirm this when I check in http://localhost:8040/v1/config/query But now I am not able to use it in my Search API, I am using the following url to verify the sort order http://localhost:8040/v1/search?q=2015%20sort:postedon<http://localhost:9070/?q=2015%20sort:postedon> I am not getting any results with the sort:postedon. I have create Element Range index & Field Range index on postedon of type date. Do I need any other index to influence the sort order of my results? is the definition of the operator right? Any tips on debugging it further would be helpful. regards, Puneet ________________________________ From: [email protected]<mailto:[email protected]> To: [email protected]<mailto:[email protected]> Date: Sat, 9 May 2015 21:21:26 +1000 Subject: [MarkLogic Dev General] Search API : defining a new operator Hi, I am trying to define an operator sort:postedon to sort the search results in descending order of the date (json-property is postedon). I am using ML8 and my data is JSON files only. Following is my xml file <options xmlns="http://marklogic.com/appservices/search"<http://marklogic.com/appservices/search%22>> <search:operator name="sort"> <search:state name="postedon"> <search:sort-order direction="descending" type="xs:date"> <search:element ns="" json-property="postedon"/> </search:sort-order> <search:sort-order> <search:score/> </search:sort-order> </search:state> </search:operator> </options> And I am applying this search option using following command curl -v -X PUT --digest --user admin:admin -H "Content-type: application/xml" -d @./SortOrder.xml 'http://localhost:8040/v1/config/query/sortorder' On running the command I am getting the following error {"errorResponse":{"statusCode":500, "status":"Internal Server Error", "messageCode":"INTERNAL ERROR", "message":"XDMP-DOCNONSBIND: xdmp:get-request-body(\"xml\") -- No namespace binding for prefix search at line 1 . See the MarkLogic server error log for further detail."}} Following is the entry in the server log 2015-05-09 21:05:49.176 Notice: carsearch: XDMP-DOCNONSBIND: xdmp:get-request-body("xml") -- No namespace binding for prefix search at line 1 2015-05-09 21:05:49.176 Notice: carsearch: in /MarkLogic/rest-api/endpoints/config-query.xqy, at 42:9 [1.0-ml] 2015-05-09 21:05:49.176 Notice: carsearch: $headers = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry<http://marklogic.com/xdmp/map%22%3e%3cmap:entry> key="content-type"><map:value xsi:type="xs:string">ap...</map:map>) 2015-05-09 21:05:49.176 Notice: carsearch: $method = "PUT" 2015-05-09 21:05:49.176 Notice: carsearch: $params = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://marklogic.com/xdmp/map"><map:entry<http://marklogic.com/xdmp/map%22%3e%3cmap:entry> key="named-option"><map:value xsi:type="xs:string">so...</map:map>) I am following the examples in manuals at https://docs.marklogic.com/guide/search-dev/query-options#id_30002 is the namespace "http://marklogic.com/appservices/search" right? Any tips to resolving it would be useful. regards, Puneet _______________________________________________ General mailing list [email protected]<mailto:[email protected]> Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
