Include offset for cropped fields #769
curquiza
started this conversation in
Feedback & Feature Proposal
Replies: 1 comment
-
@solonovamax feel free to add more details about your needs here |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Originally posted here by @solonovamax
I spent like 20 minutes writing an issue and then my browser tab decided to crash and killed all my progress, and I'm kinda annoyed about that so I'm just gonna be brief here and add more details later.
Currently, when both
showMatchesPosition
andattributesToCrop
are in use, it is difficult to use the matches position as you do not know where the crop begins.I would like to propose adding
[field]_start
and[field]_length
properties to the returned json when searching. For example, searching forminim
might return this result:then, this can be used as follows (in pseudocode)
my specific usecase: I want to add match highlighting to search results for my application. However, I cannot use the built-in highlighting as that would wrap html tags around the matches, as the content is user-supplied. So if I didn't escape the html, it would open up an avenue to XSS. But since it's escaped, wrapping the matches with html tags does not work.
And, I can't use the offset provided in the match positions, as I do not know where the content was cropped, so I don't know where the match is.
An alternative syntax to the one I suggested could be:
Beta Was this translation helpful? Give feedback.
All reactions