start chp06
from the /SolrStarterBook/test/
directory), and then open the page located at /test/chp06/html/wordclouds
.>> curl -X GET 'http://localhost:8983/solr/paintings/select?q=*:*&rows=0&facet=true&facet.field=title&wt=json'
In this simple request, we have omitted the documents from the result of (rows=0
), because we simply want to obtain facets' results.
When selecting the term saint, we will be prompted for the possibility to perform a query for the term, while we already know that there will be 22
documents matching that term. If we click on the link, a basic query will be produced:
>> curl -X GET 'http://localhost:8983/solr/paintings/select?q=title:saint&wt=json'
Where, as expected, we find 22 documents with their fields and details. This is a really simple approach, but can give a lot of interesting ideas on the context, during the prototyping phase, and can also be improved in several different ways.
If you have some experience with SQL, you can probably recognize some similarity between the faceting mechanism and the usage of the GROUP BY
clause in SQL. For example, using facet.field=artist
can be seen more or less similar to the SQL expression, SELECT P.artist, COUNT(P.artist) FROM paintings AS P GROUP BY P.artist
. With Solr, however, we can obtain results from many facets at once. (The same results will require different queries in SQL.) Moreover, the facets can be easily combined with other criteria, and they offer very good performance, because they collect values from the saved index.
52.15.65.65