{"id":976,"date":"2018-12-17T15:26:54","date_gmt":"2018-12-17T14:26:54","guid":{"rendered":"http:\/\/sematext.solr.pl\/?p=976"},"modified":"2020-11-14T15:27:19","modified_gmt":"2020-11-14T14:27:19","slug":"solr-7-6-0-uninvertible-fields","status":"publish","type":"post","link":"https:\/\/solr.pl\/en\/2018\/12\/17\/solr-7-6-0-uninvertible-fields\/","title":{"rendered":"Solr 7.6.0 &#8211; uninvertible fields"},"content":{"rendered":"\n<p>With the recent <a href=\"https:\/\/solr.pl\/en\/2018\/12\/15\/lucene-and-solr-7-6-0\/\">release of Solr 7.6.0<\/a> we got a new option for the fields and field types &#8211; the property called <strong><em>uninvertible<\/em><\/strong>. It allows us to control what Solr will do when it will require data in an uninverted format, so for example when using faceting or sorting. Let&#8217;s look into what happens with various settings of this new property.<br><\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Example data structure<br><\/h3>\n\n\n\n<p>Let&#8217;s start with a very simple data structure that we will use for testing:<\/p>\n\n\n\n<pre class=\"wp-block-code brush:xml\">&lt;field name=\"id\" type=\"string\" indexed=\"true\" stored=\"true\" required=\"true\" multiValued=\"false\" docValues=\"true\" \/&gt;\n&lt;field name=\"title\" type=\"text_general\" indexed=\"true\" stored=\"true\" multiValued=\"false\"\/&gt;\n&lt;field name=\"tags\" type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"true\" \/&gt;<\/pre>\n\n\n\n<p>Nothing special, we have three fields, one of which is the identifier. After indexing some example data let&#8217;s try running faceting on on of the field, for example the <strong><em>title<\/em><\/strong> one. In our case that shouldn&#8217;t be a problem, the query will be executed without any issues. Just for the reference, the query looks as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:xml\">http:\/\/localhost:8983\/solr\/test\/select?q=*:*&amp;facet=true&amp;facet.field=title<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><em>Adding uninvertible<\/em><\/strong><br><\/h3>\n\n\n\n<p>The next thing we should try is modifying our simple example by introducing the <strong><em>uninvertible<\/em><\/strong> property for the <strong><em>title<\/em><\/strong> field and setting it to <strong><em>true<\/em><\/strong>. Keep in mind that for backward compatibility reason this is the default value for the fields in our data structure. After we modify the schema.xml file and run the query we will still get results as we would expect. Btw, the modified data structure should look as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code brush:xml\">&lt;field name=\"id\" type=\"string\" indexed=\"true\" stored=\"true\" required=\"true\" multiValued=\"false\" docValues=\"true\" \/&gt;\n&lt;field name=\"title\" type=\"text_general\" indexed=\"true\" stored=\"true\" multiValued=\"false\" uninvertible=\"true\"\/&gt;\n&lt;field name=\"tags\" type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"true\" \/&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Solr behavior with <em><strong>uninvertible=false<\/strong><\/em><br><\/h3>\n\n\n\n<p>Let&#8217;s modify our example one last time and let&#8217;s set the <strong><em>uninvertible<\/em><\/strong> property for the <strong><em>title<\/em><\/strong> field to <strong><em>false<\/em><\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code brush:xml\">&lt;field name=\"id\" type=\"string\" indexed=\"true\" stored=\"true\" required=\"true\" multiValued=\"false\" docValues=\"true\" \/&gt;\n&lt;field name=\"title\" type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"false\" uninvertible=\"false\"\/&gt;\n&lt;field name=\"tags\" type=\"string\" indexed=\"true\" stored=\"true\" multiValued=\"true\" \/&gt;<\/pre>\n\n\n\n<p>If we would now run our example query to Solr its behavior will change. Instead of Solr returning the faceting results we would get an empty array. This is because we don&#8217;t have doc values for the title field, because we can&#8217;t have it &#8211; it is analyzed field. And with field set to <strong><em>uninvertible=false<\/em><\/strong> Solr will not allow building the field cache entries for that field.&nbsp; <br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Usage<\/h3>\n\n\n\n<p>The <strong><em>uninverible<\/em><\/strong> property should be used when we want to be sure that on our instance or in our cluster certain fields shouldn&#8217;t be used for faceting. For example, when we know that some fields are analyzed they may contain lots of unique values, which can be very memory intensive leading to high memory usage and long garbage collections. I.e. you can think of removing possibility of running facets or sorting on the analyzed fields if you don&#8217;t need it, so that no one is able to run such queries on the production environment. <br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the recent release of Solr 7.6.0 we got a new option for the fields and field types &#8211; the property called uninvertible. It allows us to control what Solr will do when it will require data in an uninverted<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[27],"tags":[610,164,611],"class_list":["post-976","post","type-post","status-publish","format-standard","hentry","category-solr-en","tag-7-6-0","tag-solr-2","tag-uninvertible"],"_links":{"self":[{"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/posts\/976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/comments?post=976"}],"version-history":[{"count":1,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/posts\/976\/revisions"}],"predecessor-version":[{"id":977,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/posts\/976\/revisions\/977"}],"wp:attachment":[{"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/media?parent=976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/categories?post=976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solr.pl\/en\/wp-json\/wp\/v2\/tags?post=976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}