#142 ✓resolved
Andy Robertson

weblinks search fails if description field in mysql db is blank and zebra index is built from it

Reported by Andy Robertson | December 16th, 2008 @ 06:12 PM

Problem is at line 395ish of search_controller.rb

A search against a weblink that does not have a description feild fails as the zebra index field for description does not exist.

All web links that have a description field are ok. Any search for a web link with a blank description field will bring back a count but when viewing the weblink it will fail with a 500 error.

This means the the weblinks link from the home site page for http://ketehamilton.peoplesnetwo... was failing to display.

A work around was to add a blank description to each of the weblinks that was failing and rebuilding the zebra index.

Here are some zebra outputs from yaz to help. searching for "day" would fail with a 500 error. Searching for "ruth" would allows a view.



Z> f @or @and @attr 1=12 ":WebLink:" @attr 2=102 @attr 5=3 @attr 5=103 @or @or @attr 1=4   "day"  @attr 1=1016   "day"   @attr 1=21 "day"  @attr 7=1 @attr 1=4  0
Sent searchRequest.
Received SearchResponse.
Search was a success.
Number of hits: 1, setno 1
SearchResult-1: term=WebLink cnt=2, term=day cnt=2, term=day cnt=6, term=day cnt=2
records returned: 0
Elapsed: 0.007248
Z> format xml
Z> show 1
Sent presentRequest (1+1).
Records: 1
[public]Record type: XML
<?xml version="1.0" encoding="UTF-8"?>
<record xmlns="http://www.openarchives.org/OAI/2.0/">
  <header>
    <identifier>oai:ketehamilton.peoplesnetworknz.info:site:WebLink:2</identifier>
    <datestamp>2008-10-20T02:59:35Z</datestamp>
  </header>
  <metadata>
    <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
      <dc:identifier>http://ketehamilton.peoplesnetworknz.info/site/web_links/show/2-childrens-day</dc:identifier>
      <dc:title>Children's Day</dc:title>
      <dc:publisher>ketehamilton.peoplesnetworknz.info</dc:publisher>
      <dc:date>2008-10-20T02:59:35Z</dc:date>
      <dc:creator>stardust</dc:creator>
      <dc:subject>Children's Day - Chartwell 07</dc:subject>
      <dc:relation>http://ketehamilton.peoplesnetworknz.info/site/topics/show/21-childrens-day-chartwell-07</dc:relation>
      <dc:type>InteractiveResource</dc:type>
      <dc:rights>ketehamilton.peoplesnetworknz.infhttp://ketehamilton.peoplesnetworknz.info/about/topics/show/4</dc:rights>
      <dc:format>text/html</dc:format>
    </oai_dc:dc>
  </metadata>
</record>
nextResultSetPosition = 2
Elapsed: 0.005446

As you can see no description field. Now ruth



Z> f @or @and @attr 1=12 ":WebLink:" @attr 2=102 @attr 5=3 @attr 5=103 @or @or @attr 1=4   "ruth"  @attr 1=1016  "ruth"  @attr 1=21 "ruth"  @attr 7=1 @attr 1=4  0
Sent searchRequest.
Received SearchResponse.
Search was a success.
Number of hits: 1, setno 2
SearchResult-1: term=WebLink cnt=3, term=ruth cnt=1, term=ruth cnt=1, term=ruth cnt=1
records returned: 0
Elapsed: 0.002478
Z> show 1
Sent presentRequest (1+1).
Records: 1
[public]Record type: XML
<?xml version="1.0" encoding="UTF-8"?>
<record xmlns="http://www.openarchives.org/OAI/2.0/">
  <header>
    <identifier>oai:ketehamilton.peoplesnetworknz.info:site:WebLink:6</identifier>
    <datestamp>2008-11-05T03:49:00Z</datestamp>
  </header>
  <metadata>
    <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
      <dc:identifier>http://ketehamilton.peoplesnetworknz.info/site/web_links/show/6-art-by-ruth-cadioli</dc:identifier>
      <dc:title>Art by Ruth Cadioli</dc:title>
      <dc:publisher>ketehamilton.peoplesnetworknz.info</dc:publisher>
      <dc:description>Art by Ruth Cadioli</dc:description>
      <dc:date>2008-11-05T03:49:00Z</dc:date>
      <dc:creator>Hudsonuh</dc:creator>
      <dc:type>InteractiveResource</dc:type>
      <dc:subject>Ruth Cadioli</dc:subject>
      <dc:subject>Art</dc:subject>
      <dc:subject>Oil on Canvas</dc:subject>
      <dc:rights>http://creativecommons.org/licenses/by-nc/3.0/nz/</dc:rights>
      <dc:format>text/html</dc:format>
    </oai_dc:dc>
  </metadata>
</record>
nextResultSetPosition = 2
Elapsed: 0.001692

If we added a description of



<p></p> 

for Children then rebuild the zebra index we can view the entry. the yaz is now.



  f @or @and @attr 1=12 ":WebLink:" @attr 2=102 @attr 5=3 @attr 5=103 @or @or @attr 1=4   "day"  @attr 1=1016   "day"   @attr 1=21 "day"  @attr 7=1 @attr 1=4  0
Sent searchRequest.
Received SearchResponse.
Search was a success.
Number of hits: 1, setno 1
SearchResult-1: term=WebLink cnt=2, term=day cnt=2, term=day cnt=6, term=day cnt=2
records returned: 0
Elapsed: 0.007022
Z> show 1
Sent presentRequest (1+1).
Records: 1
[public]Record type: XML
<?xml version="1.0" encoding="UTF-8"?>
<record xmlns="http://www.openarchives.org/OAI/2.0/">
  <header>
    <identifier>oai:ketehamilton.peoplesnetworknz.info:site:WebLink:2</identifier>
    <datestamp>2008-10-20T02:59:35Z</datestamp>
  </header>
  <metadata>
    <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
      <dc:identifier>http://ketehamilton.peoplesnetworknz.info/site/web_links/show/2-childrens-day</dc:identifier>
      <dc:title>Children's Day</dc:title>
      <dc:publisher>ketehamilton.peoplesnetworknz.info</dc:publisher>
      <dc:description/>
      <dc:date>2008-10-20T02:59:35Z</dc:date>
      <dc:creator>stardust</dc:creator>
      <dc:subject>Children's Day - Chartwell 07</dc:subject>
      <dc:relation>http://ketehamilton.peoplesnetworknz.info/site/topics/show/21-childrens-day-chartwell-07</dc:relation>
      <dc:type>InteractiveResource</dc:type>
      <dc:rights>ketehamilton.peoplesnetworknz.infhttp://ketehamilton.peoplesnetworknz.info/about/topics/show/4</dc:rights>
      <dc:format>text/html</dc:format>
    </oai_dc:dc>
  </metadata>
</record>
nextResultSetPosition = 2
Elapsed: 0.005392

the description field is there now. So I filled the remaining 8 records with no description with the same information and the search now completes happily.

The code that barfs is in searchcontroller.rb



   393      desired_fields = [['identifier', 'url'], ['title'], ['description', 'short_summary'], ['date']]
   394

   395      desired_fields.each do |field|
   396        # TODO: this xpath is expensive, replace if possible!
   397        # moving the record to a hash is much faster
   398        # but i'm stuck on how to get "from_xml" to handle namespace stuff
   399        # // xpath short cut to go right to element that matches
   400        # regardless of path that led to it
   401        # field_value = root.elements["//dc:#{field[0]}"]
   402        field_value = root.elements[field[0]]
   403        # field_value = dublin_core[field[0]]
   404        # field_value = dc_attributes["oai_dc:dc"]["dc:#{field[0]}"]
   405
   406        field_name = String.new
   407        if field[1].nil?
   408          field_name = field[0]
   409        else
   410          field_name = field[1]
   411        end
   412
   413        # value_for_return_hash = field_value
   414        value_for_return_hash = field_value.text
   415
   416        # short_summary may have some html
   417        # which is being handed back as rexml object
   418        # rather than string
   419        if field_name == 'short_summary'
   420          value_for_return_hash = prepare_short_summary(value_for_return_hash.to_s)
   421        end
   422
   423        result_hash[field_name] = value_for_return_hash
   424      end

on line 414. The description is blank so the error

NoMethodError (undefined method text' for nil:NilClass)

Is thrown.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Kete was developed by Horowhenua Library Trust and Katipo Communications Ltd. to build a digital library of Horowhenua material.

People watching this ticket

Pages