Class: Openurl

Inherits:
Object
  • Object
show all
Defined in:
lib/enju_biblio/openurl.rb

Overview


Constant Summary collapse

MATCH_EXACT =

一致条件ごとの分類

[:ndl_dpid]
MATCH_PART =

部分一致

[:aulast, :aufirst, :au, :title, :atitle, :jtitle, :btitle, :pub]
MATCH_AHEAD =

前方一致

[:issn, :isbn, :ndl_jpno]
LOGIC_MULTI_AND =

ある項目に対して複数語指定時の検索方法ごとの分類

[:au, :title, :atitle, :jtitle, :btitle, :pub]
LOGIC_MULTI_OR =

OR検索

[:ndl_dpid]
NUM_CHECK =

桁チェックが必要な項目

{issn: 8, isbn: 13}
SYNONYMS =

集約される項目

[:title, :aulast, :aufirst]
ENJU_FIELD =

enjuのフィールド名(検索用)管理

{aulast: 'au_text', # aulast=au
              aufirst: 'au_text', # aufirst=au
              au: 'au_text',
              title: 'btitle_text',  # title=btitle
              atitle: 'atitle_text',
              btitle: 'btitle_text',
              jtitle: 'jtitle_text',
              pub: 'publisher_text',
              issn: 'issn_sm',
              isbn: 'isbn_sm',
              ndl_jpno: 'ndl_jpno_text', # TODO:現在対応項目はないので保留。
              ndl_dpid: 'ndl_dpid_sm',   # TODO:現在対応項目はないので保留。これのみ完全一致であることに注意。
              associate: ''              # TODO:フィールド名ではないので削除?
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Openurl

Returns a new instance of Openurl.



41
42
43
44
45
46
47
48
49
50
# File 'lib/enju_biblio/openurl.rb', line 41

def initialize(params)
  # @openurl_queryに検索項目ごとの検索文を格納
  if params.key?(:any) then
    # anyの場合は他に条件が指定されていても無視
    @openurl_query = [params[:any].strip]
  else
    @openurl_query = to_sunspot(params)
  end
  @manifestations = []
end

Instance Attribute Details

#manifestationsObject (readonly)

Returns the value of attribute manifestations.



52
53
54
# File 'lib/enju_biblio/openurl.rb', line 52

def manifestations
  @manifestations
end

#openurl_queryObject (readonly)

Returns the value of attribute openurl_query.



52
53
54
# File 'lib/enju_biblio/openurl.rb', line 52

def openurl_query
  @openurl_query
end

#query_textObject (readonly)

Returns the value of attribute query_text.



52
53
54
# File 'lib/enju_biblio/openurl.rb', line 52

def query_text
  @query_text
end

Instance Method Details

#searchObject

検索



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/enju_biblio/openurl.rb', line 55

def search
  search = Sunspot.new_search(Manifestation)
  role = Role.default_role
  @query_text = build_query
  query = @query_text
  search.build do
    fulltext query
    with(:required_role_id).less_than_or_equal_to role.id
  end
  search.execute!.results
end