Class: Typesensual::Search::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/typesensual/search/hit.rb

Instance Method Summary collapse

Constructor Details

#initialize(hit) ⇒ Hit

{ "highlights": [ { "field": "company_name", "matched_tokens": ["Stark"], "snippet": "Stark Industries" } ], "document": { "id": "124", "company_name": "Stark Industries", "num_employees": 5215, "country": "USA" }, "text_match": 130916 }

Parameters:

  • hit (Hash)

    the Typesense hit hash

    • highlights [Array] the highlights for the hit
    • document [Hash] the matching document
    • text_match [Integer] the text matching score


26
27
28
# File 'lib/typesensual/search/hit.rb', line 26

def initialize(hit)
  @hit = hit
end

Instance Method Details

#documentObject



34
35
36
# File 'lib/typesensual/search/hit.rb', line 34

def document
  @hit['document']
end

#highlightsObject



30
31
32
# File 'lib/typesensual/search/hit.rb', line 30

def highlights
  @hit['highlights']
end

#scoreObject



38
39
40
# File 'lib/typesensual/search/hit.rb', line 38

def score
  @hit['text_match']
end