/// <summary> /// return the best fragments. /// </summary> /// <param name="fieldQuery"><see cref="FieldQuery"/> object</param> /// <param name="reader"><see cref="IndexReader"/> of the index</param> /// <param name="docId">document id to be highlighted</param> /// <param name="fieldName">field of the document to be highlighted</param> /// <param name="fragCharSize">the length (number of chars) of a fragment</param> /// <param name="maxNumFragments">maximum number of fragments</param> /// <returns> /// created fragments or null when no fragments created. /// size of the array can be less than maxNumFragments /// </returns> /// <exception cref="IOException">If there is a low-level I/O error</exception> public string[] GetBestFragments(FieldQuery fieldQuery, IndexReader reader, int docId, string fieldName, int fragCharSize, int maxNumFragments) { FieldFragList fieldFragList = GetFieldFragList(fragListBuilder, fieldQuery, reader, docId, fieldName, fragCharSize); return(fragmentsBuilder.CreateFragments(reader, docId, fieldName, fieldFragList, maxNumFragments)); }
/// <summary> /// Return the best fragments. Matches are scanned from <paramref name="matchedFields"/> and turned into fragments against /// <paramref name="storedField"/>. The highlighting may not make sense if <paramref name="matchedFields"/> has matches with offsets that don't /// correspond features in <paramref name="storedField"/>. It will outright throw a <see cref="IndexOutOfRangeException"/> /// if <paramref name="matchedFields"/> produces offsets outside of <paramref name="storedField"/>. As such it is advisable that all /// <paramref name="matchedFields"/> share the same source as <paramref name="storedField"/> or are at least a prefix of it. /// </summary> /// <param name="fieldQuery"><see cref="FieldQuery"/> object</param> /// <param name="reader"><see cref="IndexReader"/> of the index</param> /// <param name="docId">document id to be highlighted</param> /// <param name="storedField">field of the document that stores the text</param> /// <param name="matchedFields">fields of the document to scan for matches</param> /// <param name="fragCharSize">the length (number of chars) of a fragment</param> /// <param name="maxNumFragments">maximum number of fragments</param> /// <param name="fragListBuilder"><see cref="IFragListBuilder"/> object</param> /// <param name="fragmentsBuilder"><see cref="IFragmentsBuilder"/> object</param> /// <param name="preTags">pre-tags to be used to highlight terms</param> /// <param name="postTags">post-tags to be used to highlight terms</param> /// <param name="encoder">an encoder that generates encoded text</param> /// <returns> /// created fragments or null when no fragments created. /// size of the array can be less than <paramref name="maxNumFragments"/> /// </returns> /// <exception cref="IOException">If there is a low-level I/O error</exception> public string[] GetBestFragments(FieldQuery fieldQuery, IndexReader reader, int docId, string storedField, ISet <string> matchedFields, int fragCharSize, int maxNumFragments, IFragListBuilder fragListBuilder, IFragmentsBuilder fragmentsBuilder, string[] preTags, string[] postTags, IEncoder encoder) { FieldFragList fieldFragList = GetFieldFragList(fragListBuilder, fieldQuery, reader, docId, matchedFields, fragCharSize); return(fragmentsBuilder.CreateFragments(reader, docId, storedField, fieldFragList, maxNumFragments, preTags, postTags, encoder)); }