… queries When the users enters an incorrect query, _Tire_ raises a `Tire::Search::SearchRequestFailed` exception. It is unfortunate to propagate the raw exception to the page, and display the “Something went wrong” page in this case -- it's better to display the default result set, or the search form, and indicate to the user her query was incorrect. This commit contains a trivial implementation via the _Rails'_ `rescue_from` method. See <http://github.com/karmi/tire/issues/164#issuecomment-3096189>.
…names Based on previous refactoring, we're now addding a specific mapping for the `author` property, so that it's analyzed as "multi field" property. This means it's: 1. Split into tokens the usual way search engine works, with the snowball analyzer. 2. Left "as is", without any modification, as an "exact" sub-property. This illustrates one of the usual use-cases for multi field properties: you want to search against them as usual, but you also want to use their literal, unmodified value for aggregations. This allows us to get rid of database calls (`Author.find(facet['term'])`) in the view layer, and use information already in the index for displaying the faceted navigation sidebar. Notice we facet against the `author.name.exact` field, and that we have changed the mechanics of limiting results based on user's choice in right-hand sidebar: instead of query, we are using filter, again on the `author.name.exact` field. This means, the **query** is used to limit the results, but **faceted navigation** still displays the distribution of results among authors, when you limit the results to a specific author, because a **filter** is used; facets are bound only by queries, not filters. See <http://www.elasticsearch.org/guide/reference/api/search/facets/index.html> for more information.
In the published version, special methods `Article#author_name` and `Article#comments_count` were added, so we can display some data about authorship and comments from associations. This would be less then ideal in a bigger codebase, and, moreover, Elasticsearch & Tire make it trivial to support this use case. The only thing we need to do is to `include` the selected information from the associated models in the `Article#to_indexed_json` declaration. In this way, the information about: * Name of the article author * Name of commenters and bodies of their comments is included in the index. This has two benefits: 1. It's **searchable**! :) We can search within the comments in the same way as we do within articles. 2. We don't have to add special methods, and can revert the HTML layer to the original state.
…ds on article.author