Hi Tanaya,
I notice a few things here..
* “i” is highlighted because i is the stem of me (cts:stem("me”) ==> i).
You can avoid that by adding the “unstemmed” option to your word-query
* Tags are normally not highlighted, meaning you are passing in tags a
plain text, not as xml. E.g. $final-result contains plain text, not xhtml..
* Your replacement span uses plain text for the tags as well. Instead of
the concat, try <span class=“highlight”>{ cts:text }</span>. That is generally
a better approach..
Cheers,
Geert
From:
<[email protected]<mailto:[email protected]>>
on behalf of "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Thursday, December 10, 2015 at 12:08 PM
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] MarkLogic highlights wrong content when
searched
Hi,
I am trying to search some content and highlight the search strings present in
the content(like google) in MarkLogic using REST API. The problem is when I am
including "ME" in the search-string, it's highlighting the <i> (html italic
tags) along with the "Me" in the content. I have created a field with some
elements and running a word-query on the field.
For example:
<resources>
<title> some data from me</title>
<desc> more data <i> from </i> somewhere by me </desc>
</resources>
I have created a field called 'suggestions' with elements 'title' and 'desc'
and searching the search strings within the field using word-query.
Now when i search for "some me" ,its retrieving the content like
<resources>
<title> <<span class="highlight">some</span> data from <<span
class="highlight">me</span></title>
<desc> more data <<span class="highlight">i</span>> from <<span
class="highlight">i</span>> somewhere by <<span class="highlight">me</span>
</desc>
</resources>
Url:
localhost:9000/v1/search?q=some
me&collection=Data&start=0&pageLength=10&options=Transformation&format=json
I am using cts:highlight for highlighting, something like :
cts:highlight($final-result, $query, fn:concat('<span
class="highlight">',$cts:text,'</span>')), $custom-config)
Trying to understand if there is any grammar for which ‘Me’ and ‘I’ are treated
as same? Or there is some problem with HTML tag parsing.
Looking forward for a prompt reply.
Thanks in Advance.
Regards,
Tanaya Mondal
Programmer Analyst
This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient(s), please reply to the sender and
destroy all copies of the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email,
and/or any action taken in reliance on the contents of this e-mail is strictly
prohibited and may be unlawful. Where permitted by applicable law, this e-mail
and other e-mail communications sent to and from Cognizant e-mail addresses may
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general