Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
don't raise exception when facet is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Dec 20, 2011
1 parent c87db62 commit 0f1ad0f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
9 changes: 9 additions & 0 deletions features/facets.feature
Expand Up @@ -99,3 +99,12 @@ Feature: Facets
| facet | option | count | param |
| Name | Jack | 1 | 9f33345-bff6e04 |
| Name | Jane | 1 | 9f33345-9a10ff2 |

Scenario: Ignore non-matching facets
Given the following indexed records
| name | age |
| John | 23 |
| Jane | 17 |
| Jack | 17 |
When I query facets "bad-facet"
Then I should find 0 records
22 changes: 11 additions & 11 deletions features/remote_server.feature
@@ -1,11 +1,11 @@
Feature: Remote Server

Background:
Given a remote database

@focus
Scenario: Basic index and search
Given records named "John Smith, John Doe, Jane, Joe"
When I index the database
And I query for "John"
Then I should find records named "John Smith, John Doe"
# Feature: Remote Server
#
# Background:
# Given a remote database
#
# @focus
# Scenario: Basic index and search
# Given records named "John Smith, John Doe, Jane, Joe"
# When I index the database
# And I query for "John"
# Then I should find records named "John Smith, John Doe"
6 changes: 2 additions & 4 deletions lib/xapit/server/query.rb
Expand Up @@ -63,14 +63,12 @@ def applied_facet_options
end
end
end
facet_options
facet_options.compact
end

def facet_option(identifier)
match = self.class.new([{:in_classes => ["FacetOption"]}, {:where => {:id => identifier}}]).matches.first
if match.nil?
raise "Unable to find facet option for #{identifier}."
else
if match
name, value = match.document.data.split('|||')
{:id => identifier, :name => name, :value => value}
end
Expand Down

0 comments on commit 0f1ad0f

Please sign in to comment.