[MarkLogic Dev General] Search API snippet
Danny.Sokolsky at marklogic.com
Thu Jun 10 09:03:31 PDT 2010
Or you can always write your own snippet function and hook it up to the Search API. Then you can do whatever you like.
The basic pattern for specifying your own function is described in the section immediately following the one that Shannon mentioned, titled "Specifying Your Own Code in transform-results".
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Shannon
Sent: Wednesday, June 09, 2010 8:42 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Search API snippet
Pradeep, as a work-around to the undesired behavior, I modified asc:transform-result in standard.xqy, to inspect each result, and if the query is found only in an element that contains metadata, which is unsuitable for display in results, then my preferred element is returned instead (conveniently in this case each document in the TEI data contained an abstract element, so I chose it)--I know it's not recommended to use static snippets, but it was better than the default in the current release, and it works especially well when you're drilling down a large dataset using faceted range constraints (another instance in which the default snippets aren't useful). You might take this approach of transforming snippets in your response output whether or not you're using Application Builder.
On Jun 9, 2010, at 12:14 PM, Pradeep Maddireddy wrote:
> Hi Shanon
> That mapping helps only if the search term is found in multiple
> elements, it will return all those elements, we can also control the
> element to be preferred.
> But in my case, if the search term is only found in title and no where
> else, search API only returns the title element as snippet which
> doesn't have enough text to be displayed on search results page.
> Pradeep Maddireddy
> On 6/9/10, Shannon <Shiflett at virginia.edu> wrote:
>> Hi Pradeep,
>> Check out section 18.104.22.168 of Search Developer's Guide: max-snippet-chars and
>> preferred-elements child elements of the transform-results options node
>> should address those requirements.
>> On Jun 9, 2010, at 10:48 AM, Pradeep Maddireddy wrote:
>>> I always want atleast 300 to 400 char of snippet to be returned by
>>> the search API.
>>> Is there any setting that would help me get 300 to 400 char of snippet.
>>> Most of the times when the hit is aginst a title or author element
>>> only that particular element is being returned as snippet, this will
>>> not be enough text to be displayed in the search results screen.
>>> Pradeep Maddireddy
>>> General mailing list
>>> General at developer.marklogic.com
>> General mailing list
>> General at developer.marklogic.com
> General mailing list
> General at developer.marklogic.com
General mailing list
General at developer.marklogic.com
More information about the General