[ https://issues.apache.org/jira/browse/LUCENE-3243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13055610#comment-13055610 ]
Jahangir Anwari commented on LUCENE-3243: ----------------------------------------- Hi Koji, Sorry for not elaborating more on our requirements and our implementation. Basically for every search result we needed the position(word offset) information of the search hits in the document. On the search result page, this position offsets information was embedded in the search result links. When the user clicked on a search link, at the target page using javascript and the position offset information we would highlight the search terms. To return the position offset information along with the highlighted snippet we created a CustomSolrHighlihter(attached). Depending on the type of query the custom highlighter returns the position offsets information. # Non-phrase query: Using FieldTermStack we return the term position offset for the terms in the query. # Phrase query: Using the WeightedFragInfo.fragInfos we return the term position offset for the terms in the query. But currently the Toffs(Term offsets) class only stores the start and end offset and so we updated it so that it would store the position information as well. Answers to your questions: * *What is the position offset? Isn't it just a position?* Yes, it is just the position. * *Why is the position offset String?* Since for phrase queries(e.g. "divine knowledge") the position-gap between terms == 1, WeightedPhraseInfo would only store the startOffset(i.e 12) of the first term of the phrase terms and the endOffset(i.e. 29) of the phrase terms. {code} [startOffset, endOffset] "divine knowledge": [(12,29)] {code} But as we needed position information(i.e. 5,6) of all the terms it required storing the position of the terms of a phrase query as a String. {code} [startOffset, endOffset, positions] "divine knowledge": [(12,29, [5,6])] {code} * *Why do you need setPositionOffset()?* setPositionOffset() is used to store the positions of consecutive terms of a phrase query. For every terms of the phrase query it just appends the argument position to the current position(i.e. [5,6]). P.S. In order to able to override doHighlightingByFastVectorHighlighter() method in CustomSolrHighlighter we had to change the access modifier for alternateField() and getSolrFragmentsBuilder() to protected. > FastVectorHighlighter - add position offset to > FieldPhraseList.WeightedPhraseInfo.Toffs > --------------------------------------------------------------------------------------- > > Key: LUCENE-3243 > URL: https://issues.apache.org/jira/browse/LUCENE-3243 > Project: Lucene - Java > Issue Type: Improvement > Components: modules/highlighter > Affects Versions: 3.2 > Environment: Lucene 3.2 > Reporter: Jahangir Anwari > Priority: Minor > Labels: feature, lucene > Attachments: CustomSolrHighlighter.java, LUCENE-3243.patch.diff > > > Needed to return position offsets along with highlighted snippets when using > FVH for highlighting. > Using the ([LUCENE-3141|https://issues.apache.org/jira/browse/LUCENE-3141]) > patch I was able to get the fragInfo for a particular Phrase search. > Currently the Toffs(Term offsets) class only stores the start and end offset. > To get the position offset, I added the position offset information in Toffs > and FieldPhraseList class. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org