1

Does https://crate.io support facets (for faceted search)?

I didn't find anything in the docs. ElasticSearch replaced facets with aggregations in 2014, but the aggregation section in the crate docs only talks about SQL aggregation functions.

My use case: I've got a list of web sites, each record has a domain and a language field. When displaying the search results, I want to get a list of all domains that the search results appear in, as well a list of all languages, ordered by number of occurences so search results can be narrowed down. The number of results for those single facet values shall also be given.

Screenshot with facets: screenshot

Cœur
  • 37,241
  • 25
  • 195
  • 267
cweiske
  • 30,033
  • 14
  • 133
  • 194

2 Answers2

1

There is no way to get the facets I want from crate itself.

Instead we're enabling the ElasticSearch REST API in crate.yml now

es.api.enabled: true

.. and can use the ElasticSearch aggregation API.

cweiske
  • 30,033
  • 14
  • 133
  • 194
1

Crate doesn't support facets or Elasticsearch aggregations directly. Like you suggested, you can always turn on the Elasticsearch API. However, there are other ways to get these aggregations.

1) Have you considered to issue multiple queries to the cluster? For example, if you load your page dynamically with Javascript, you can first return the search results and load the facets later. This should also decrease the overall response time of the application.

2) In CrateDB 2.1.x, there will be support for subqueries, which allow you to include the facets within your query:

select q1.id, q1.domain, q1.tag, q2.d_count, q3.t_count  from websites q1,
(select domain, count(*) as d_count from websites where text like '%query%' group by domain) q2,
(select tag, count(*) as t_count from websites where text like '%query%' group by tag) q3
where q1.domain = q2.domain and q1.tag = q3.tag and q1.text like '%query%'
order by q1.id
limit 5;

This gives you a result table like this where you have the search results alongside with the domain and tag count for the query:

+----+--------------+-----------+---------+-----------+
| id | domain       | tag         | d_count | t_count |
+----+--------------+-------------+---------+---------+
|  1 | example.com  | example     |       2 |       3 |
| 14 | crate.io     | software    |       1 |       4 |
| 17 | google.com   | search      |       5 |       2 |
| 29 | github.com   | open-source |       3 |       3 |
| 47 | linux.org    | software    |       2 |       4 |
+----+--------------+-------------+---------+---------+

Disclaimer: I'm new to Crate :)

mxm
  • 605
  • 5
  • 13