Time for action – creating wordclouds on facets to view and analyze data

  1. Using the faceting capabilities of Solr, it is really simple to produce a wordcloud or tagcloud. These are very good visualization tools, because they can be used not only for their aesthetics but also to synthesize visually a weighted list of terms from the domain in which we are moving into. I have prepared some really simple examples of this using only HTML and JavaScript code, using the simple and powerful jqcloud (http://www.lucaongaro.eu/demos/jqcloud/) library:
    Time for action – creating wordclouds on facets to view and analyze data
  2. All we have to do to play with them, and eventually customize the examples is to start Solr in the usual way (for example, calling start chp06 from the /SolrStarterBook/test/ directory), and then open the page located at /test/chp06/html/wordclouds.
  3. In this example, we can see that terms are presented in a sparse visualization, and the word size visually represents its relevance in the context. For example, the terms presented in the middle box are collected from the title field using the faceting capabilities of Solr:
    >> 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.

What just happened?

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.

Tip

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.65.65