README.rdoc in xapian_db-0.5.5 vs README.rdoc in xapian_db-0.5.6
- old
+ new
@@ -153,10 +153,14 @@
You can query objects of a specific class:
results = Person.search "name:Foo"
+You can search for exact phrases:
+
+ results = XapianDb.search('"this exact sentence"')
+
If you want to paginate the result, pass the :per_page argument:
results = Person.search "name:Foo", :per_page => 20
If you want to limit the number of results, pass the :limit argument (handy if you use the query for autocompletion):
@@ -184,16 +188,21 @@
results.spelling_suggestion # "mouse"
The results behave like an array:
doc = results.first
+ puts doc.score.to_s # Get the relevance of the document
puts doc.indexed_class # Get the type of the indexed object as a string, e.g. "Person"
puts doc.name # We can access the configured attributes
person = doc.indexed_object # Access the object behind this doc (lazy loaded)
Use a search result with will_paginate in a view:
<%= will_paginate @results %>
+
+Or with kaminari:
+
+ <%= kaminari @results %>
=== Facets
If you want to implement a simple drilldown for your searches, you can use a global facets query: