app/models/multi_class_search.rb
# So-called "self-healing" code for pages that have no native node and were probably deleted:
So-called "self-healing" code for pages that have no native node and were probably deleted.
So - called " self - healing " code for pages that have no native node and were probably deleted .
def remove_zombie_pages
    bad_page_ids = []
    @pages.each do |page|
      id =  if page.respond_to?(:page_id) 
              page.page_id
            else
              page.id
            end
      bad_page_ids << id if page.native_node.nil?
    end
    return if bad_page_ids.empty?
    Page.where(id: bad_page_ids).includes(:nodes).each do |page|
      if page.nodes.empty?
        Page.search_index.remove(page)
        page.delete
      end
    end
    begin 
      @pages.response["hits"]["hits"].delete_if { |hit| bad_page_ids.include?(hit["_id"]) }
    rescue
    end
  end
def remove_zombie_pages bad_page_ids = [ ] @pages . each do | page | id = if page . respond_to? ( :page_id ) page . page_id else page . id end bad_page_ids << id if page . native_node . nil? end return if bad_page_ids . empty? Page . where ( id : bad_page_ids ) . includes ( :nodes ) . each do | page | if page . nodes . empty? Page . search_index . remove ( page ) page . delete end end begin @pages . response [ "hits" ] [ "hits" ] . delete_if { | hit | bad_page_ids . include? ( hit [ "_id" ] ) } rescue end end
So-called "self-healing" code for pages that have no native node and were probably deleted:
So - called " self - healing " code for pages that have no native node and were probably deleted :
# Search decotrator # This is really reaching into the innards of the class, but I can't find an alternative: # Nothing we can do, it will render a "NO NAME!" result, which is better than the alternative.