Class: DocsKit::SearchIndex::Entry
- Inherits:
-
Struct
- Object
- Struct
- DocsKit::SearchIndex::Entry
- Defined in:
- lib/docs_kit/search_index.rb
Overview
An indexed section (or page intro). haystacks holds the lowercased text of
each weighted field so scoring is a simple include? per token.
The page title is searchable ONLY on the page-intro entry (section_title nil), not on every section: a title token matches all sections of a page equally, so weighting each section by the title would flood the results with near-identical rows from one page. A pure title match therefore surfaces once (the intro), while a section still ranks on its own heading/body.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#href ⇒ Object
Returns the value of attribute href.
-
#page_title ⇒ Object
Returns the value of attribute page_title.
-
#section_title ⇒ Object
Returns the value of attribute section_title.
Instance Method Summary collapse
-
#haystacks ⇒ Object
{ weight => lowercased searchable text } for this entry.
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
43 44 45 |
# File 'lib/docs_kit/search_index.rb', line 43 def body @body end |
#href ⇒ Object
Returns the value of attribute href
43 44 45 |
# File 'lib/docs_kit/search_index.rb', line 43 def href @href end |
#page_title ⇒ Object
Returns the value of attribute page_title
43 44 45 |
# File 'lib/docs_kit/search_index.rb', line 43 def page_title @page_title end |
#section_title ⇒ Object
Returns the value of attribute section_title
43 44 45 |
# File 'lib/docs_kit/search_index.rb', line 43 def section_title @section_title end |
Instance Method Details
#haystacks ⇒ Object
{ weight => lowercased searchable text } for this entry.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/docs_kit/search_index.rb', line 45 def haystacks @haystacks ||= begin fields = { HEADING_WEIGHT => section_title.to_s.downcase, BODY_WEIGHT => body.to_s.downcase } fields[TITLE_WEIGHT] = page_title.to_s.downcase if section_title.nil? fields end end |