[MarkLogic Dev General] Best Way to Learn How To Craft Geo Queres
Michael Blakeley
mike at blakeley.com
Mon Apr 9 09:13:33 PDT 2012
I think you can do all that using the search API: http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/apidoc/searchapi.xml&category=Search&function=search:search - look at the configuration examples, especially "<geo-*>".
From Java you could invoke it via a simple wrapper in XQuery, something like this. The most complex part will be configuring the options. Those will be specific to your application and XML.
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
(: external variables are set by the Java XCC Request setNewStringVariable et. al. :)
declare variable $QUERY as xs:string external;
declare variable $PAGE-START as xs:integer external;
declare variable $PAGE-SIZE as xs:integer external;
declare variable $OPTIONS :=
<options xmlns="http://marklogic.com/appservices/search">
{
(: add extra configuration - geospatial, etc. :)
}
</options>
;
search:search($QUERY, $OPTIONS, $PAGE-START, $PAGE-SIZE)
If you want to learn more about how you might implement the search API functionality, you might have a look at http://developer.marklogic.com/learn/2006-09-paginated-search - but these days most applications use the higher-level search API.
-- Mike
On 9 Apr 2012, at 08:47 , Tom Hubschman wrote:
> Hey All,
>
> Not sure if I missed a reply to this one. Didn't see it, but for some reason I don't get direct replies with this engine. I looked for it in list setting but couldn't find it.
>
> Thanks,
>
> Tom
>
> On Tue, Apr 3, 2012 at 4:12 PM, Tom Hubschman <tom.hubschman at warriorgateway.org> wrote:
> Hi Justin,
>
> Thanks for the quick reply. The existing query I have is definitely a good start but I imagine I could gain greater performance by having more of the logic executed in the XQuery "stored procedure." (I am using XCC with Java).
>
> Specifically what I need in my geo-query is the following:
> • An AND query between some key words and a location. (Key Words and Location are the inputs)
> • The results (The Output) should be ranked by both the and query and the location
> • Results where the key words appear more often should be returned higher up.
> • Results where the location is closer should appear higher up
> • The results to be paginated.
> • The ability to specify how many results to return with one call.
> • The ability to specify what "page" of results to return,
> • The confidence that the pagination is consistent (result position is constant if there are no edits/additions/deletions).
> Regarding performance I just need the best that ML/XQuery can do. Some of the above I am currently doing in Java which I know is impacting the performance (I want to do all sorting/paging/ranking in XQuery/MarkLogic).
>
> Thanks again
>
> Tom
>
>
>
> --
> Thomas Hubschman
> Director, Engineering
> tom.hubschman at warriorgateway.org
> Mobile: (415) 612-0359
> www.warriorgateway.org
>
>
>
> --
> Thomas Hubschman
> Director, Engineering
> tom.hubschman at warriorgateway.org
> Mobile: (415) 612-0359
> www.warriorgateway.org
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
More information about the General
mailing list