shibukawa / oktavia

Full text search engine for JS environments
MIT License
70 stars 11 forks source link

include search word in exracted content. #25

Open tuchida opened 10 years ago

tuchida commented 10 years ago

Make extracted content that begin at hit word position and extends to +125 char.

tuchida commented 10 years ago

For example, I made search index of this html file.

<div>Long string of 250 characters or more</div>
<div>あいうえお</div>
<div>Long string of 125 characters or more</div>

When I search for 'あいうえお', it hit but search result does not include search word.

If the file does not have a search word between 0 to 250 the characters, will try to split the content. https://github.com/shibukawa/oktavia/blob/8ed26702c90994b621dc426dd16f84debe728799/src/oktavia-web-runtime.jsx#L242

But starting position is -Math.floor(num / 2), the split content been made of string that begin index at content.length - 125. https://github.com/shibukawa/oktavia/blob/8ed26702c90994b621dc426dd16f84debe728799/src/oktavia-web-runtime.jsx#L263