Sini,
In built app, we do a POST on /v1/search endpoint and pass in a structured
query as the payload. Here are some examples (this is against the example Oscar
application)
1. When I enter a search string ('Peck') in the search text box,
- the URL to post looks like
http://localhost:8003/v1/search?format=json&view=all&options=all&start=1&pageLength=10
- the structured query in the payload looks like
{"query":{"qtext":"Peck"}}
2. When I enter a search string ('Peck') in the search text box, and
click on a facet on the side bar (lead-actor)
- the URL to post looks like
http://localhost:8003/v1/search?format=json&view=all&options=all&start=1&pageLength=10
- the structured query in the payload looks like
{"query":{"qtext":"Peck","and-query":{"queries":[{"range-constraint-query":{"constraint-name":"award","value":["lead-actor"]}}]}}}
3. If I were to restrict the search based on a constraint (by entering
the constraint name in the search box),
- the URL to post looks like
http://localhost:8003/v1/search?format=json&view=all&options=all&start=1&pageLength=10
- the structure query would look like
{"query":{"qtext":"decade:1930s"}}
I used firebug to trace the calls. Hope this helps to answer your question #3.
You can do a POST to /vi/search, specify format as JSON, specify the options
name (which by default with app builder built apps is 'all) and pass the
structured query in the pay load to POST.
With this, I am not sure if you need to do #4 and #5. Hope this helps.
Ganesh Vaideeswaran
Director of Engineering, Application Services
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 650 655 2398
www.marklogic.com<http://www.marklogic.com/>
This e-mail and any accompanying attachments are confidential. The information
is intended solely for the use of the individual to whom it is addressed. Any
review, disclosure, copying, distribution, or use of this e-mail communication
by others is strictly prohibited. If you are not the intended recipient, please
notify us immediately by returning this message to the sender and delete all
copies. Thank you for your cooperation.
From: [email protected]
[mailto:[email protected]] On Behalf Of sini narayanan
Sent: Monday, February 11, 2013 5:34 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Search Query
Hi David,
Thanks. I have already gone through the search and rest-api guides. But I'm
still not able to figure out a solution for my requirement.
I have the an application built using app builder. I have done some
customization in the application. The customization is as below:
1. When a user performs a search and clicks on the "Export" link (custom link
created) in the results page, a new document is getting generated in the DB.
2. The new document created in the DB has the json query string as an entry in
it.
Example of the document in DB:
<QueryString>{"text":"","page":1,"facets":{"city":{"constraintType":"range","noShadow":true,"value":["Paris"]}}}</QueryString>
3. Now, what I need to know is, how do I reproduce my search results by
executing this json query string?
4. It is said that the json has to be converted into xml. Which is the function
that I should use, json:transform-from-json() OR xdmp:from-json?
5. If I get an xml format, how do I call the search:search to perform the
query. In the above example, I need to search for city:Paris.
Please help.
Thanks,
Sini
On Mon, Feb 11, 2013 at 5:51 PM, David Lee
<[email protected]<mailto:[email protected]>> wrote:
Ultimately AppBuilder ends up using search:search or cts:search in "the back
end" (MarkLogic DB).
JSON is converted to XML to perform the searches.
A good start for understanding search concepts from the server perspective is :
http://docs.marklogic.com/guide/search-dev
JavaScript code in AppBuilder uses the REST API which under the hood uses the
above.
http://docs.marklogic.com/guide/rest-dev
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224<tel:%2B1%20812-482-5224>
Cell: +1 812-630-7622<tel:%2B1%20812-630-7622>
www.marklogic.com<http://www.marklogic.com/>
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
On Behalf Of sini narayanan
Sent: Sunday, February 10, 2013 11:57 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Search Query
Hi all,
How exactly is the search happening at the backend when we search for a
particular document in the application builder?
Is it in json format or something else. Please calrify.
In the controller.js file, I noticed that the query string formed is in json
format. Is this json query converted into some other format to search the DB?
If I have a json query, how do I search DB with the same.
For example: If i have the json query like below, can I use the same to query
the DB seperately in QC.
{"text":"","page":1,"facets":{"city":{"constraintType":"range","noShadow":true,"value":["Paris"]}}}
Thanks,
Sini
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general