[opencms-dev] Solr Query
Диканский Андрей Юрьевич
adikanskii at ncfu.ru
Tue May 31 08:45:43 CEST 2022
Thanks for your recommendatrions. I'll check it.
PS: we are using 10.5.4
________________________________
От: opencms-dev <opencms-dev-bounces at opencms.org> от имени Daniel Seidel via opencms-dev <opencms-dev at opencms.org>
Отправлено: 31 мая 2022 г. 9:42
Кому: opencms-dev at opencms.org
Копия: Daniel Seidel
Тема: Re: [opencms-dev] Solr Query
Hi again,
there's one more hint about your search configuration - at least since OpenCms 12. It seems that you do not use any of the configuration options of the search configuration it the sense that you have a for where you can change sort order or filter by facet etc.
If you only search in a preconfigured way, you may use the plain seach configuration instead of the JSON one.
In your case (without the adjustments suggested in my last mail) this would be:
<c:set var="solrNewsQuery">q=*:*&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&rows=3000</c:set>
The index I would omit. If you omit it, Solr Offline will be chosen offline and Solr Online online. That's typically the intended behavior.
One more hint: The results are restricted by default to at most 400. If you need more results, you have to adjust configuration, e.g. via "maxProcessedResults", see here: https://documentation.opencms.org/opencms-documentation/more-opencms-features/solr-search-integration/basic-solr-configuration/index.html.
Best, Daniel.
Am 31.05.22 um 08:34 schrieb Daniel Seidel via opencms-dev:
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
_______________________________________________
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/7c50d5e3/attachment.htm>
More information about the opencms-dev
mailing list