Elasticsearch get position of phrase in document -


i'm working on project need full-text search book. need search in 1 book @ time , need offset of search term beginning of book. need site that's powered django/python think elasticsearch better , faster.

so far haven't used elasticsearch directly through abstraction layer django-haystack.

edit1: need display users not text searching link them text. should work search box in preview on mac. users see search results surrounding text , if click on redirected js part of book, text located.

will simple highlighting suffice? if not, brute-force solution set highlighting pre_tags programmably-identifiable value , calculate offset that. speed setting term_vector with_positions_offsets in mapping use lucene's fast-vector-highlighter:

{     "type_name" : {         "content" : {"term_vector" : "with_positions_offsets"}     } } 

if that's not acceptable, check out this answer information on how offsets stored internally.

edit: based on edit, i'm not sure how having offset much. mean, unless you're displaying preformatted text or other fixed layout, how know on rendered page offset corresponds?

i think elegant solution use pre_tags , post_tags wrap matched text in elements. use javascript assign each match id, creating new fragment identifiers can set location.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -