我在Rails应用程序中使用Searchkick和Elasticsearch创建了高亮功能。
像这样:
def index
@book_searches = Book.search(params[:query], operator: "or", fields: [:description], highlight: {tag: "<strong>", fields: {description: {number_of_fragments: 3, fragment_size: 100}}})
@chapter_searches = Chapter.search(params[:query], operator: "or", fields: [:body], highlight: {tag: "<strong>", fields: {body: {number_of_fragments: 3, fragment_size: 100}}})
end
除 number_of_fragments 部分外,一切正常。有人有解决方案吗?
我正在寻找类似于论文的结果:
Search for "minimum wage"
Returns "a **minimum wage** rate maximum number of hours overtime pay child labor (see ... to pay a **minimum wage** and overtime to many employees, it also contains ... Pennsylvania’s **Minimum Wage** Act currently sets the minimum wage at the same rate ..."
它返回大约三个在文本正文中彼此分开的句子和(...)。