'Solr /admin/luke requests sometimes return nulls
I'm trying to get some metadata (document count and last modified date) from Solr, and found /solr/<core>/admin/luke endpoint to do it.
However, my requests sometimes return nulls instead of values. I can reproduce it via both SolrJ and curl:
✗ curl hostname/solr/core_name/admin/luke -s | jq '.index.lastModified'
"2019-06-04T19:59:45.617Z"
✗ curl hostname/solr/core_name/admin/luke -s | jq '.index.lastModified'
null
Without jq results are either:
{
"responseHeader":{
"status":0,
"QTime":2},
"index":{
"numDocs":11,
"maxDoc":11,
"deletedDocs":0,
"indexHeapUsageBytes":-1,
"version":6,
"segmentCount":1,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NRTCachingDirectory:NRTCachingDirectory(MMapDirectory@ ... lockFactory=org.apache.lucene.store.NativeFSLockFactory@2846d2cf; maxCacheMB=48.0 maxMergeSizeMB=4.0)",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":-1,
"userData":{
"commitTimeMSec":"1559730066881",
"commitCommandVer":"1635495514608762880"},
"lastModified":"2019-06-05T10:21:06.881Z"},
"fields":{ .... },
"info":{ .... }
}
or:
{
"responseHeader":{
"status":0,
"QTime":2},
"index":{
"numDocs":11,
"maxDoc":11,
"deletedDocs":0,
"indexHeapUsageBytes":-1,
"version":4,
"segmentCount":1,
"current":false,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NRTCachingDirectory:NRTCachingDirectory(MMapDirectory@ .... lockFactory=org.apache.lucene.store.NativeFSLockFactory@1e10c435; maxCacheMB=48.0 maxMergeSizeMB=4.0)",
"segmentsFile":"segments_1",
"segmentsFileSizeInBytes":-1,
"userData":{}},
"fields":{ .... },
"info":{ .... }
}
I've omitted part of index.directory, fields and info. The difference is in version, current, userData and lastModified, everything else looks the same.
I'm using Solr 7.5 in Cloud mode. My collections are on multiple shards with replicas = 2 (or more). I've tried adding ?numTerms=50 to request, but it doesn't help.
Is there something I can do to always receive correct response?
Solution 1:[1]
.index.lastModified is calculated from .index.userData.commitTimeMSec by the Luke Request Handler. That's why the last three digits are always the same.
If your core hasn't had any commits yet, .index.userData is empty and Luke simply doesn't add .index.lastModified to the response. That's what you're seeing on your second request.
From LukeRequestHandler.java:
String s = userData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
if (s != null) {
indexInfo.add("lastModified", new Date(Long.parseLong(s)));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thomas |
