[opencms-dev] Solr Query

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


Thank you!


It works! You helped me a lot!




________________________________
От: opencms-dev <opencms-dev-bounces at opencms.org> от имени Daniel Seidel via opencms-dev <opencms-dev at opencms.org>
Отправлено: 31 мая 2022 г. 9:34
Кому: opencms-dev at opencms.org
Копия: Daniel Seidel
Тема: Re: [opencms-dev] Solr Query


Hi,


you are using the wrong Solr field. If you map use


<solrfield targetfield="contentdate" sourcefield="*_dt"/>


your field names will be "contentdate_{locale}_dt".


If you use a recent version of OpenCms, I'll recommend using the fieldsettings syntax (https://documentation.opencms.org/opencms-documentation/content-in-opencms/defining-a-content-type/defining-the-contents-behavior/field-settings/index.html) for the mapping and with "listdate" (https://documentation.opencms.org/opencms-documentation/content-in-opencms/defining-a-content-type/defining-the-contents-behavior/search-settings/index.html#short-cut-syntax-for-the-most-relevant-search-settings).


Probably the date field will also be the best field for sorting.


Best, Daniel.


Am 31.05.22 um 08:23 schrieb Диканский Андрей Юрьевич via opencms-dev:

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?




_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
https://lists.opencms.org/mailman/listinfo/opencms-dev





--
Kind Regards

Daniel.

-------------------

Daniel Seidel
Alkacon Software GmbH & Co. KG - The OpenCms Experts
https://www.alkacon.com - http://www.opencms.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20220531/381a14ca/attachment.htm>


More information about the opencms-dev mailing list