Time for action – posting some example data

Now that we have prepared the system and installed Solr, we are ready to post some example data as suggested by the default tutorial. In order to check if our installation is working as expected, we need to perform the following steps:

  1. We can easily post some of the example data contained in the /example/exampledocs folder of our Solr installation. First of all, we move to that directory using the following command:
    >> cd %SOLR_DIST% (windows)
    >> cd $SOLR_DIST (linux, mac)
    
  2. Then we will index some data using the post.jar library provided, using the following command:
    >> java -jar post.jar .
    
  3. In the /example/exampledocs subfolder, you can find some documents written using the XML, CSV, or JSON format that Solr recognizes to index the data. The post.jar Java library is designed to send every file contained in a directory (in this case, the current directory). This library is written in one of these formats to a running Solr instance, in this case the default one. The data is sent by an HTTP POST request, and this should explain the name.
  4. Once the example data is indexed, we can again run a query with simple parameters, as shown in the following screenshot:
    Time for action – posting some example data
  5. Here, we are able to see some results exposed by default using the json format. The example data describes items in a hypothetical catalog of electronic devices.

What just happened?

As you can see in the screenshot, the results are recognizable as items inside a docs collection; we can see the first, which has both fields containing a single value or multiple values (these are easily recognizable by the [ , ] JSON syntax for lists). The header section of the results contains some general information. For example, the query sent (q=*:*, which basically means "I want to obtain all the documents") and the format chosen for the output (in our case JSON). Moreover, you should note that the number of results is 32, which is bigger than the number of files in that directory. This should suggest to us that we send more than one single document in a single post (we will see this in the later chapters).

Lastly, you can see in the address that we are actually querying over a subpath called collection1. This is the name of the default collection where we have indexed our example data. In the next chapter, we will start using our first collection instead of this example one.

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

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