{"_id":"5787db28e516ba0e003046f8","parentDoc":null,"user":"5633ec9b35355017003ca3f2","__v":5,"project":"56be3387be55991700c3ca0d","category":{"_id":"5787da96b008c91900aae865","__v":0,"project":"56be3387be55991700c3ca0d","version":"56be3388be55991700c3ca10","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-14T18:31:50.937Z","from_sync":false,"order":3,"slug":"troubleshooting","title":"Troubleshooting"},"version":{"_id":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","__v":8,"createdAt":"2016-02-12T19:33:28.313Z","releaseDate":"2016-02-12T19:33:28.313Z","categories":["56be3389be55991700c3ca11","57646709b0a8be1900fcd0d8","5764671c89da831700590782","57646d30c176520e00ea8fe5","5764715d4f867c0e002bc8e3","57698fa2e93bfd190028815c","576c2af16c24681700c902da","5787da96b008c91900aae865"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-14T18:34:16.977Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Partial results occur when Solr can not complete a query in a reasonable amount of time. Time limits on queries are enforced both to keep Solr from hanging your app, and to prevent other tenants on the server from tying up system resources at the expense of other users. Partial results manifest themselves in several ways:\n\n- Returning 0 documents for a term that is known to be present\n- Returning an inconsistent number of results for a given term\n- Alternating between returning 0 results and all (or most) results\n\n# Detecting Partial Results\n\nYou can tell when you are getting partial results because there will be a `partialResults` flag set to `true` in the response header. In JSON, this looks like:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\\"responseHeader\\\":\\n\\t{\\\"status\\\":0,\\n\\t\\t\\\"partialResults\\\":true,\\n    \\\"QTime\\\":200,\\n    \\\"params\\\":{\\\"wt\\\":\\\"json\\\"}\\n\\t},\\n\\\"response\\\":{\\\"numFound\\\":7793,\\\"start\\\":0,\\\"docs\\\":[ ... ]}}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nXML responses will also have a `partialResults` tag present.\n\n# Why does this happen?\n\nThere are generally two types of situations where partial results can arise:\n\n1. **You perform an expensive query on a large index.** If you ask for a term that occurs 100,000 times in your index (or make use of the wildcard operator `*`, functionQueries, etc), we may only be able to evaluate the first 20,000 matching documents before the maximum allowed query time has elapsed.\n2. **Insufficient system resources.** In a cloud environment, the IO of the underlying instances can fluctuate. If we do not have enough available IO to complete your request in a timely manner, we will search as much as we can in a short amount of time, and return what we have found.\n\n# Reacting to Partial Results\n\nThere are a few strategies for dealing with partialResults. The quickest and easiest method is to have the application check the results for the `partialResults` flag, and retry the search if it's detected. This way you can benefit from the caching of any query filters and document results.\n\nYou could also look at optimizing your queries. Typically, a Solr client will automatically construct a query based on parameters it receives from the app, but this is not always done in an intelligent way. For example, Sunspot has been known to create queries like this:\n\n```\nq=*:*&fq=year_added:[2012+TO+*]&fq=year_added:[*+TO+2014]...\n```\n\nWhere the heavy use of the wildcard operator is completely unnecessary an inefficient. **Wildcards are the least efficient means of pattern matching in Solr,** and consume a surprisingly large amount of CPU. Generally we advise users to avoid these where possible. So, continuing from the previous example, something like this would be far more effective:\n\n```\nq=*:*&fq=year_added:[2012+TO+2014]...\n```\n\nDepending on the data being indexed, and average document sizes, you may simply need more memory than the averages our plans' document recommendations are based on. Please contact us for an analysis of the size of your index so that we can recommend a more appropriate service level for your needs.","excerpt":"Learn how to detect and fix partial results with Solr.","slug":"partial-results","type":"basic","title":"Partial Results"}

Partial Results

Learn how to detect and fix partial results with Solr.

Partial results occur when Solr can not complete a query in a reasonable amount of time. Time limits on queries are enforced both to keep Solr from hanging your app, and to prevent other tenants on the server from tying up system resources at the expense of other users. Partial results manifest themselves in several ways: - Returning 0 documents for a term that is known to be present - Returning an inconsistent number of results for a given term - Alternating between returning 0 results and all (or most) results # Detecting Partial Results You can tell when you are getting partial results because there will be a `partialResults` flag set to `true` in the response header. In JSON, this looks like: [block:code] { "codes": [ { "code": "{\"responseHeader\":\n\t{\"status\":0,\n\t\t\"partialResults\":true,\n \"QTime\":200,\n \"params\":{\"wt\":\"json\"}\n\t},\n\"response\":{\"numFound\":7793,\"start\":0,\"docs\":[ ... ]}}", "language": "json" } ] } [/block] XML responses will also have a `partialResults` tag present. # Why does this happen? There are generally two types of situations where partial results can arise: 1. **You perform an expensive query on a large index.** If you ask for a term that occurs 100,000 times in your index (or make use of the wildcard operator `*`, functionQueries, etc), we may only be able to evaluate the first 20,000 matching documents before the maximum allowed query time has elapsed. 2. **Insufficient system resources.** In a cloud environment, the IO of the underlying instances can fluctuate. If we do not have enough available IO to complete your request in a timely manner, we will search as much as we can in a short amount of time, and return what we have found. # Reacting to Partial Results There are a few strategies for dealing with partialResults. The quickest and easiest method is to have the application check the results for the `partialResults` flag, and retry the search if it's detected. This way you can benefit from the caching of any query filters and document results. You could also look at optimizing your queries. Typically, a Solr client will automatically construct a query based on parameters it receives from the app, but this is not always done in an intelligent way. For example, Sunspot has been known to create queries like this: ``` q=*:*&fq=year_added:[2012+TO+*]&fq=year_added:[*+TO+2014]... ``` Where the heavy use of the wildcard operator is completely unnecessary an inefficient. **Wildcards are the least efficient means of pattern matching in Solr,** and consume a surprisingly large amount of CPU. Generally we advise users to avoid these where possible. So, continuing from the previous example, something like this would be far more effective: ``` q=*:*&fq=year_added:[2012+TO+2014]... ``` Depending on the data being indexed, and average document sizes, you may simply need more memory than the averages our plans' document recommendations are based on. Please contact us for an analysis of the size of your index so that we can recommend a more appropriate service level for your needs.