Module: WikidataAdaptor::RestApi::SearchProperty

Included in:
WikidataAdaptor::RestApi
Defined in:
lib/wikidata_adaptor/rest_api/search_property.rb

Overview

Instance Method Summary collapse

Instance Method Details

#search_properties(query, lang, limit: 10, offset: 0) ⇒ Hash

Simple Property search by label and aliases

Parameters:

  • query (String)

    The search query, for example "taxon".

  • lang (String)

    The language to search labels in, for example "en".

  • limit (Integer) (defaults to: 10)

    The maximum number of results to return.

  • offset (Integer) (defaults to: 0)

    The number of results to skip (for pagination).

Returns:

  • (Hash)

    Search results.



15
16
17
18
19
20
21
22
23
# File 'lib/wikidata_adaptor/rest_api/search_property.rb', line 15

def search_properties(query, lang, limit: 10, offset: 0)
  params = {
    q: query,
    lang: lang,
    limit: limit,
    offset: offset
  }
  get_json("#{endpoint}/v0/search/properties", params: params)
end

#suggest_properties(query, lang, limit: 10, offset: 0) ⇒ Hash

Simple Property search by prefix, for labels and aliases

Parameters:

  • query (String)

    The search query prefix, for example "taxon".

  • lang (String)

    The language to search labels in, for example "en".

  • limit (Integer) (defaults to: 10)

    The maximum number of results to return.

  • offset (Integer) (defaults to: 0)

    The number of results to skip (for pagination).

Returns:

  • (Hash)

    Suggestion results.



33
34
35
36
37
38
39
40
41
# File 'lib/wikidata_adaptor/rest_api/search_property.rb', line 33

def suggest_properties(query, lang, limit: 10, offset: 0)
  params = {
    q: query,
    lang: lang,
    limit: limit,
    offset: offset
  }
  get_json("#{endpoint}/v0/suggest/properties", params: params)
end