[opencms-dev] Solr Query

Диканский Андрей Юрьевич adikanskii at ncfu.ru
Tue May 31 08:23:23 CEST 2022


Hello, All!


I need to select some news and output JSON.


I have following code in my News schema:


<xsd:complexType name="OpenCmsEnNews">
<xsd:sequence>
<xsd:element name="Title" type="OpenCmsString"/>
<xsd:element name="ShortDescription" type="OpenCmsString"/>
<xsd:element name="ImagePreview" type="OpenCmsVfsFile"/>
<xsd:element name="Date" type="OpenCmsDateTime"/>
<xsd:element name="FullDescription" type="OpenCmsHtml"/>
<xsd:element name="Category" type="OpenCmsCategory"/>
<xsd:element name="PublishTime" type="OpenCmsPublishTime" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
</xsd:complexType>



<searchsettings containerPageOnly="false">
        <searchsetting element="Date" searchcontent="false">
          <solrfield targetfield="contentdate" sourcefield="*_dt"/>
        </searchsetting>



I made solr query like this:


<c:set var="searchPath">${cms.requestContext.siteRoot}/</c:set>
<c:set var="cat" value="${param.cat}" />
<c:set var="start" value="${param.start}" />
<c:set var="end" value="${param.end}" />
<c:set var='solrNewsQuery'>
{
"core" : "Solr Online",
"ignorequery" : true,
"ignoreReleaseDate" : false,
"ignoreExpirationDate" : false,
"queryparam" : ":",
"escapequerychars" : true,
"extrasolrparams" : "fq=parent-folders:\"${searchPath}\"&fq=type:EnNews&fq=category:${cat}&fq=contentdate:[${start}T00:00:00Z TO ${end}T23:59:59Z]&sort=Newsdate_prop desc",
"pagesize" : "3000",
}
</c:set>
<cms:search configString="${solrNewsQuery}" var="search" addContentInfo="true" />
[
<c:forEach var="news" items="${search.searchResults}" varStatus="status">
.....



I made a query with certain period of data and expect a list of news. But some news are missing in output. If I change in extrasolrparams "contentdate" to "created" then missing news are presented in output.

But it is convinient for me to get news by Date property not by created attribute.


I guess the problem is in indexing Date property. I tried to publish again missed news, but nothig changed.


Can any one help me with selecting news by Date property?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20220531/2cd34411/attachment.htm>


More information about the opencms-dev mailing list