Class: Ecfr::SearchService::ContentVersion::Suggestion

Inherits:
Ecfr::SearchService::ContentVersion show all
Defined in:
lib/ecfr/search_service/content_version/suggestion.rb

Constant Summary collapse

SUGGESTIONS_PATH =
"v1/suggestions"

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 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

#global_search_resultsInteger (readonly)

total number of matching full text search results

Returns:

  • (Integer)


41
42
43
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 41

 :global_search_results,
type: :integer,
desc: "total number of matching full text search results"

#headingsEcfr::Common::Hierarchy (readonly)

the descriptive portion of the CFR level



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

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



32
33
34
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 32

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



35
36
37
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 35

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

#highlightString (readonly)

text containing ‘<mark>’ tags the denote where the query was found by the search engine - only type: ‘autocomplete’

Returns:

  • (String)


7
8
9
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 7

attribute :highlight,
          desc: "text containing '<mark>' tags the denote where the query was
found by the search engine - only type: 'autocomplete'"

#narrowed_hierarchyEcfr::Common::Hierarchy (readonly)

the hierarchy that the narrowed_search_results have been limited to



48
49
50
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 48

 :narrowed_hierarchy,
type: Ecfr::Common::Hierarchy,
desc: "the hierarchy that the narrowed_search_results have been limited to"

#narrowed_search_resultsInteger (readonly)

number of search results that match the current hierarchy

Returns:

  • (Integer)


44
45
46
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 44

 :narrowed_search_results,
type: :integer,
desc: "number of search results that match the current hierarchy"

#removedDate (readonly)

the date that this portion of the CFR that was removed

Returns:

  • (Date)


19
20
21
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 19

attribute :removed,
type: :date,
desc: "the date that this portion of the CFR that was removed"

#reservedBoolean (readonly)

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 15

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

#structure_indexInteger (readonly)

an integer representing the location of the suggestion in the source xml for it’s corresponding title. Useful for sorting. Only type: ‘autocomplete’

Returns:

  • (Integer)


23
24
25
26
27
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 23

attribute :structure_index,
          type: :integer,
          desc: "an integer representing the location of the suggestion in the
source xml for it's corresponding title. Useful for sorting. Only
type: 'autocomplete'"

#typeString (readonly)

the type of suggestion, currently ‘cfr_reference’ or ‘autocomplete’

Returns:

  • (String)


12
13
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 12

attribute :type,
desc: "the type of suggestion, currently 'cfr_reference' or 'autocomplete'"

Class Method Details

.find(args) ⇒ <Suggestion>

Retreive suggestions for the given search args

Parameters:

  • args (<Hash>)

    see: Result.find @option Boolean autocomplete Adding autocomplete=true to the request

    will return suggestions of type 'autocomplete'
    

Returns:

  • (<Suggestion>)

    by default suggestions will be of type ‘cfr_reference’ and are useful for refining full text search requests. When autocomplete=true has been added to the request then suggestions will be of type ‘autocomplete’ and are useful for typeahead style searches



66
67
68
69
70
71
72
# File 'lib/ecfr/search_service/content_version/suggestion.rb', line 66

def self.find(args)
  perform(
    :get,
    SUGGESTIONS_PATH,
    params: args.except(:order, :page, :per_page).stringify_keys
  )
end