Solr provides you with a really slick web interface you can use to look at the raw data living in your indexes. It gives you access to current memory levels, index sizes (both file size and how many documents are contained in the index), as well the ability to query the data. This is a tool I use nearly every day and this blog post will take you through how to use it.
To access the Solr web console you If you have your project set up to use the Solr content search layer, you will be able to access the Solr web console by finding the Sitecore setting: ContentSearch.Solr.ServiceBaseAddress. The value of that setting should look something similar to: http://localhost:8080/solr.
Depending on the size of your indexes, and most likely the usage, you will need to increase the memory settings that come default with Tomcat. To give you an idea we have increased the Initial Memory Pool to 512mb and the Maximum Memory Pool to 4096mb. These settings can be found in the Java tab of the tomcat7w application located in Tomcat’s bin folder.
If you are looking for some basic information regarding your index the Core Admin is where you want to go. It provides you with a quick snapshot: when it was started, modified, number of documents, optimized etc…
Quick Document Updates Directly in Solr
Select an index from the dropdown and go to the Documents link in the left hand navigation. This page allows you to run scripts against your index where you can do many things such as add/update/remove field values. I would suggest it is better to go back to Sitecore and rebuild the index, but if you need a quick fix and cannot wait for the index to rebuild this tool will come in handy. Here are some quick examples:
Now let’s get into the fun stuff. Here is where you will spend 98% of your time. The query window in the Solr web console gives you so much power to perform pagination, sorting, selecting specific fields (instead of all fields), filtering, output formatting and much more.
A couple things to note… One is if we run the default query, notice the fields that are returned. Some are prefixed by an underscore while other have a suffix. What does this all mean? The fields that are prefixed with an underscore are defined specifically in the schema.xml file. When Sitecore generates the schema.xml file, it adds these standard fields in such as _language. This schema.xml file is located in each core’s conf folder. Dynamic and Computed fields are not hardcoded into the schema.xml file. These fields do not have the underscore prefix but rather have a suffix which indicates their data type. For example a single line text field in Sitecore would look like someStringField_s and an int would look like someIntField_i.
Secondly, above the search results you will see a link. If you click that it will bring you to the raw output of what you are requesting. This is exactly how Sitecore queries Solr. It makes HTTP requests and consumes and parses Solr’s response. If you take apart the url, you will see the request handler (update), query, sort and any other piece you threw at it. Let’s break it apart:
http://localhost:8081/solr/airports_index/select?q=_language:en && (city_s:Boston || city_s:”New Orleans”)&sort=title_s asc&start=0&rows=3&fl=_language, title_s,city_s,id_s&wt=json&indent=true
- The targeted index: http://localhost:8081/solr/airports_index
- Request Handler: /select
- Query: q=_language:en && (city_s:Boston || city_s:”New Orleans”)
- Sort: sort=title_s asc
- Pagination Start: start=0
- Pagination Span: rows=3
- Fields: fl=_language, title_s,city_s,id_s
- Format: wt=json
Knowing that, let’s learn how to do some querying! For starters the default query is: *:*. Now let’s say we want to bring back all documents that are associated with the English language. The query we will apply will look like this, _language:en. Let’s continue expanding. We can use the && to append to our query and target not only language but the city field. Our query has now evolved into _language:en && city_s:Boston. One thing to keep in mind is if you have a space in your string you will need to wrap that with parenthesis as shown in the screenshot below. For additional search operators take a look at this post which will talk about others in more detail: http://www.solrtutorial.com/solr-query-syntax.html
I hope this provided some valuable information on how to use the Solr Web Console. If you have any questions or want me to expand on any points feel feel to reach out.