Hi David,

There are 3 parts to the suggestion feature.

 One is the Javascript portion, which handles the user interface portion.

The second is the XQuery portion;  in REST API terms it is an extension.  If 
you look at documentation for how to install and manage extensions, you'll find 
instructions on how to install extensions.  You can take the module from App 
Builder and install it in the other environment.

The third is a small bit of configuration that associates the suggestion 
capability with the range index or field that you want to derive suggestions 
from.  When the App Builder deploys an application, it stores a set of search 
options that includes the necessary bit of configuration. You can look at a 
list of stored options configurations at /v1/config/query (GET); I believe that 
you want "all" (odd naming, but that's what App Builder does).  You can store a 
similar set of search options in your target environment to drive your 
suggestion interface.

And Tim is right, RoXY does have some nice conveniences for working with REST 
extensions.

--Colleen

________________________________
From: [email protected] 
[[email protected]] on behalf of Steiner, David J. 
(LNG-DAY) [[email protected]]
Sent: Thursday, December 12, 2013 8:12 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Lifting a portion of App Builder app to use in 
a different place

I built an app using App Builder and I also have a separate app that I built by 
just using xquery, html, jquery javascript, etc….

The separate app operates on a database that is different from the one that the 
App Builder app operates on.  However, I’d like to incorporate the “search 
suggestion” of the App Builder app in my separate app.

I found the code for the suggestion in “search.js”.

I see that there is an endpoint in it for the search suggestion: 
/v1/resources/extsuggest" + '?rs:pqtxt='

Ideally, I guess, I’d like to be able to incorporate the appropriate HTML, 
javascript and css in my separate app, add the 
http://host:port/<UrlBlockedError.aspx> to the front of the endpoint and have 
the suggestion just work.

Has anyone ever attempted this?

I can also write a service that would replicate what the suggestion endpoint is 
doing, but I’d rather not if I don’t have to, so if anyone has any experience 
in doing this, I’d appreciate the guidance.  By the way, I started the service 
and I’m sure that it’ll have to do something different since it appears that 
there are extra backslashes and quotes that need to be inserted to make it good 
json (I noticed this by looking at the difference between my output and the 
output of the app builder extension?

I’ve already gotten this far in my test page, which I’ve created just to see if 
I can get the suggestion to work.  I tried sticking the fully qualified 
location in the suggestEndpoint variable (i.e., adding 
http://host:port<UrlBlockedError.aspx> to the front of the url) in search.js 
and nothing really happened, so I’m assuming that perhaps there’s configuration 
stuff that I’m skipping, or possibly a wide variety of things that are missing…

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Title</title>
  <link rel="stylesheet" 
href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css";>
  <link type="text/css" rel="stylesheet" 
href="application/lib/viz/search/search.css" media="screen, print"/>
  <script src="http://code.jquery.com/jquery-1.9.1.min.js";></script>
  <script 
src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js";></script>
  <script src="application/lib/viz/search/search.js" 
type="text/javascript"></script>
</head>
<body>
<div data-role="page" data-theme="d" id="myPage">
        <div data-role="header">
                <h1>Header.</h1>
        </div>
        <div class="content-primary">
           <div id="search" class="search widget"></div>
        </div>
        <div class="content-secondary">
        </div>
</div>
</body>
<script>
var search = ML.createSearch("search");
</script>
</html>

Thanks for any help,
David
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to