Class: Ecfr::SearchService::ContentVersion::Result

Inherits:
Ecfr::SearchService::ContentVersion show all
Extended by:
Constants::ChangeTypes, ResponseHelper
Defined in:
lib/ecfr/search_service/content_version/result.rb,
lib/ecfr/testing/extensions/search_service/content_version_result_extensions.rb

Constant Summary collapse

RESULTS_PATH =
"v1/results"

Constants included from Constants::ChangeTypes

Constants::ChangeTypes::KNOWN_CHANGE_TYPES

Constants inherited from Base

Base::SUPPORTED_ARRAY_ACCESSORS

Instance Attribute Summary collapse

Attributes inherited from Base

#metadata, #request_data, #response_status, #results

Class Method Summary collapse

Methods included from ResponseHelper

stubbed_response

Methods inherited from Ecfr::SearchService::ContentVersion

count, hierarchical_search, search, suggestions, summary

Methods inherited from Base

base_url, service_name, service_path

Methods inherited from Base

basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key

Methods included from Extensible

#inherited

Methods included from AttributeMethodDefinition

included, #initialize

Methods inherited from Client

build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge

Methods included from ParallelClient

included

Constructor Details

This class inherits a constructor from Ecfr::Base

Instance Attribute Details

#change_types[:symbol] (readonly)

array of change types that corresponds to the keys in Constants::ChangeTypes::KNOWN_CHANGE_TYPES

Returns:

  • ([:symbol])


22
23
24
# File 'lib/ecfr/search_service/content_version/result.rb', line 22

attribute :change_types,
type: Array(:symbol),
desc: "array of change types that corresponds to the keys in {KNOWN_CHANGE_TYPES}"

#current_pageInteger (readonly)

current page of results

Returns:

  • (Integer)


55
56
57
# File 'lib/ecfr/search_service/content_version/result.rb', line 55

 :current_page,
type: :integer,
desc: "current page of results"

#descriptionString (readonly)

description of the search results

Returns:

  • (String)


52
53
# File 'lib/ecfr/search_service/content_version/result.rb', line 52

 :description,
desc: "description of the search results"

#ends_onDate (readonly)

the last date this version of the content appeared in the eCFR

Returns:

  • (Date)


33
34
35
# File 'lib/ecfr/search_service/content_version/result.rb', line 33

attribute :ends_on,
type: :date,
desc: "the last date this version of the content appeared in the eCFR"

#full_text_excerptString (readonly)

excerpt of text where matching keywords were found

Returns:

  • (String)


9
10
# File 'lib/ecfr/search_service/content_version/result.rb', line 9

attribute :full_text_excerpt,
desc: "excerpt of text where matching keywords were found"

#headingsEcfr::Common::Hierarchy (readonly)

the descriptive portion of the CFR level



40
41
42
# File 'lib/ecfr/search_service/content_version/result.rb', line 40

attribute :headings,
type: Ecfr::Common::Hierarchy,
desc: "the descriptive portion of the CFR level"

#hierarchyEcfr::Common::Hierarchy (readonly)

the shortened identifier portion of the CFR level



43
44
45
# File 'lib/ecfr/search_service/content_version/result.rb', line 43

attribute :hierarchy,
type: Ecfr::Common::Hierarchy,
desc: "the shortened identifier portion of the CFR level"

#hierarchy_headingsEcfr::Common::Hierarchy (readonly)

the full identifier portion of the CFR level



46
47
48
# File 'lib/ecfr/search_service/content_version/result.rb', line 46

attribute :hierarchy_headings,
type: Ecfr::Common::Hierarchy,
desc: "the full identifier portion of the CFR level"

#max_dateDate (readonly)

the maximum date of all returned results

Returns:

  • (Date)


76
77
78
# File 'lib/ecfr/search_service/content_version/result.rb', line 76

 :max_date,
type: :date,
desc: "the maximum date of all returned results"

#max_scoreFloat (readonly)

the maximum score of any match in the search

Returns:

  • (Float)


65
66
67
# File 'lib/ecfr/search_service/content_version/result.rb', line 65

 :max_score,
type: :float,
desc: "the maximum score of any match in the search"

#min_dateDate (readonly)

the minimum date of all returned results

Returns:

  • (Date)


71
72
73
# File 'lib/ecfr/search_service/content_version/result.rb', line 71

 :min_date,
type: :date,
desc: "the minimum date of all returned results"

#removedBoolean (readonly)

whether the result represents a part of the CFR that has been removed

Returns:

  • (Boolean)


29
30
31
# File 'lib/ecfr/search_service/content_version/result.rb', line 29

attribute :removed,
type: :boolean,
desc: "whether the result represents a part of the CFR that has been removed"

#reservedBoolean (readonly)

whether the result represents a portion of the CFR that is Reserved

Returns:

  • (Boolean)


26
27
28
# File 'lib/ecfr/search_service/content_version/result.rb', line 26

attribute :reserved,
type: :boolean,
desc: "whether the result represents a portion of the CFR that is Reserved"

#scoreFloat (readonly)

numerical representation of ranking within results

Returns:

  • (Float)


14
15
16
# File 'lib/ecfr/search_service/content_version/result.rb', line 14

attribute :score,
type: :float,
desc: "numerical representation of ranking within results"

#starts_onDate (readonly)

the first date this version of the content appeared in the eCFR

Returns:

  • (Date)


36
37
38
# File 'lib/ecfr/search_service/content_version/result.rb', line 36

attribute :starts_on,
type: :date,
desc: "the first date this version of the content appeared in the eCFR"

#structure_indexInteger (readonly)

index of where content was found in relation to other content within the title - used for sorting

Returns:

  • (Integer)


18
19
20
# File 'lib/ecfr/search_service/content_version/result.rb', line 18

attribute :structure_index,
type: :integer,
desc: "index of where content was found in relation to other content within the title - used for sorting"

#total_countInteger (readonly)

total count of matching results across all pages

Returns:

  • (Integer)


58
59
60
# File 'lib/ecfr/search_service/content_version/result.rb', line 58

 :total_count,
type: :integer,
desc: "total count of matching results across all pages"

#total_pagesInteger (readonly)

total number of pages in the search results

Returns:

  • (Integer)


61
62
63
# File 'lib/ecfr/search_service/content_version/result.rb', line 61

 :total_pages,
type: :integer,
desc: "total number of pages in the search results"

#typeString (readonly)

the content type returned - either Appendix or Section

Returns:

  • (String)


11
12
# File 'lib/ecfr/search_service/content_version/result.rb', line 11

attribute :type,
desc: "the content type returned - either *Appendix* or *Section*"

Class Method Details

.find(args) ⇒ [<Result>]

Retrieve results of search query

Parameters:

  • args (<Hash>)

    supported search parameters; supported params:

Options Hash (args):

  • :agency_slugs (Array)

    limit search to portions of the CFR these agencies are currently associated with (see Ecfr::AdminService::Agency)

  • :date (String)

    ISO date or ‘current’

  • :last_modified_after (String)

    ISO date

  • :last_modified_before (String)

    ISO date

  • :last_modified_on_or_after (String)

    ISO date

  • :last_modified_on_or_before (String)

    ISO date

  • :order (String)

    relevance, hierarchy, newest_first, oldest_first

  • :page (Integer)

    page of search results to return

  • :per_page (Integer)

    number of results per page

  • :paginate_by (String)

    one of “results” or “date” if “date” then one of the last_modified_* options is required

  • :query (String)

    search terms

Returns:

  • ([<Result>])

    an array of results with metadata



101
102
103
104
105
106
107
# File 'lib/ecfr/search_service/content_version/result.rb', line 101

def self.find(args)
  perform(
    :get,
    RESULTS_PATH,
    params: args.compact
  )
end

.response_for(content_versions) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ecfr/testing/extensions/search_service/content_version_result_extensions.rb', line 4

def self.response_for(content_versions)
  content_versions = content_versions.is_a?(Array) ? content_versions : [content_versions]

  results = {
    results: content_versions,
    meta: content_versions.first.fetch("meta", nil)
  }.compact

  build(
    response: stubbed_response(results.to_json)
  )
end