Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Documenting indexed_models setting, finally.

  • Loading branch information...
commit 28cf64bc84d6e15f7b6444c01d2347dbecba5eae 1 parent acbfacd
@pat authored
Showing with 22 additions and 3 deletions.
  1. +14 −0 ts/en/advanced_config.textile
  2. +8 −3 ts/en/common_issues.textile
View
14 ts/en/advanced_config.textile
@@ -154,3 +154,17 @@ Article.search 'pancakes',
:max_matches => 10_000,
:per_page => 10_000
{% endhighlight %}
+
+<h3 id="indexed-models">Indexed Models</h3>
+
+While not related to Sphinx, this setting is to provide faster loading of the indexed models by Thinking Sphinx. Normally, Thinking Sphinx has to load _all_ models to determine which ones are indexed. This is not ideal, so if you like, you can explicitly list the relevant models in your @config/sphinx.yml@ file:
+
+{% highlight yaml %}
+development:
+ indexed_models:
+ - Article
+ - Company
+ - User
+{% endhighlight %}
+
+Given a standard production environment does not re-initialize the app on every request, this is only useful in development. And make sure you remember to update it if you add index definitions to models!
View
11 ts/en/common_issues.textile
@@ -26,6 +26,7 @@ Depending on how you have Sphinx setup, or what database you're using, you might
* "Using other Database Adapters":#other_adapters
* "Using OR Logic with Attribute Filters":#or_attributes
* "Catching Exceptions when Searching":#exceptions
+* "Slow Requests (Especially in Development)":#slow-page-requests
<h3 id="editconf">Editing the generated Sphinx configuration file</h3>
@@ -100,7 +101,7 @@ If you've got a field that is built off multiple values in one column - ie: thro
{% highlight rb %}
define_index do
# ...
-
+
set_property :group_concat_max_len => 8192
end
{% endhighlight %}
@@ -116,10 +117,10 @@ A common example is if you're converting latitude and longitude columns from deg
{% highlight ruby %}
define_index do
# ...
-
+
has "RADIANS(latitude)", :as => :latitude, :type => :float
has "RADIANS(longitude)", :as => :longitude, :type => :float
-
+
group_by "latitude", "longitude"
end
{% endhighlight %}
@@ -283,3 +284,7 @@ Obviously, if you're chaining scopes together, make sure you add this at the end
{% highlight ruby %}
Article.published.search :populate => true
{% endhighlight %}
+
+<h3 id="slow-page-requests">Slow Requests (Especially in Development)</h3>
+
+If you're finding a lot of requests are quite slow (particularly in your local development environment), this could be because you have a lot of models. Thinking Sphinx loads all models to determine which ones are indexed by Sphinx (this is necessary to load search results), but you can make things much faster by setting out "a list of indexed models":/en/ts/advanced_config.html#indexed-models in your @config/sphinx.yml@ file.
Please sign in to comment.
Something went wrong with that request. Please try again.