Advacne search- new Date Filter Plugin issue for Compound Field

Hello All,

We are adding a new Filter fields for Coremetadata (Available Date,Refrenece date) for filtering the content based on available and refrence date in dcoument search in CMS.

I have created a new custiomezed plugin class for Date. But Result are not filerting if doing the search for CoreMetadata field but same Plugin is working fine If we do the search for Document Date field.

I have gone through the document but not found a example for Compound fields search.

Can anyone pls suggest how to get the Coremetadata fields for below code snippet.

Here are the code snappnet i was trying:
List constraints = new LinkedList();

List constraints = new LinkedList();

addDateConstraints(constraints, “myproject:CoreMetadata\myproject:date_available”, availableDateFrom, availableDateTo); – Not giving any result tried with “ftcore:date_available”)
List constraints = new LinkedList();

addDateConstraints(constraints, “myproject:CoreMetadata\myproject:date”, DateFrom, DateTo); - Working the for Document field.

Code:

@Override

public List<Constraint> getConstraints() {

    List<Constraint> constraints = new LinkedList();

addDateConstraints(constraints, “myproject:CoreMetadata\myproject:date_available”, availableDateFrom, availableDateTo);

    addDateConstraints(constraints, "myproject:CoreMetadata\myproject:date__reference", visibleReferenceFrom, visibleReferenceTo);

    return constraints;

}

private void addDateConstraints(final List<Constraint> constraints, final String property, final Date dateAfter,

        final Date dateBefore) {

    if (dateAfter != null) {

        final LowerBoundedDateConstraint constraint = QueryUtils.date(property).from(dateAfter);

        constraints.add(constraint);

        if (dateBefore != null) {

            constraint.andTo(dateBefore);

        }

    } else if (dateBefore != null) {

        constraints.add(QueryUtils.date(property).to(dateBefore));

    }

}

Thanks in advance for your help.

Hi,
The date property name (e.g. myproject:date__reference) should be the actual JCR property on the document. I’m not sure referencing a property of a subnode (compound) works here, but if it does, the reference should contain a forward slash rather than a backward one.

You can set INFO log level to class org.onehippo.cms7.services.search.jcr.service.HippoJcrSearchService to see what XPath query was executed.

HTH
Jeroen

Thanks Jeroen for your reply.

I have alreday tried with (/,\ and without slash) but its search is not performed and not filtering the result in advance search.

Node Structre of coremetadata and its property: (CoreMetadata is defualt porvided metadata with CMS).

So what does the HippoJcrSearchService produce on INFO level? You can take it’s XPath and replay it on the /repository/ servlet. I would expect path “ftcore:coreMetadata/ftcore:date__reference” in there. If it is, but doesn’t work, this kind of customization only works on actual document properties and you’d have to copy the property by means of derived data function, see [1]

HTH
Jeroen

[1] https://documentation.bloomreach.com/14/library/concepts/content-repository/derived-data.html

Yes i am able to get the query. Looking at the query I can see its taking the coremetadata @date_valid_until property. If i will search using this property in search repository i am getting the result. so I belive issue is not with compound metadata.

But my observation is that other parameters of the query like hippostd:publishable , hippo:availability etc are required for any field search for advance serach in defalut query. These parameter are not available on any compound nodes or deep node of the document hence Zero result are return.

Could you pls provide any clue how to chnage these parameter in advance serach query or what else can be done to make search query work
//element(*,hippostd:publishable)[(@hippo:paths=‘ed307dfc-5774-4ac7-9feb-79b57e058bb2’) and ((@hippo:availability = ‘preview’ or (@hippo:availability = ‘live’)) –

Query:
//element(*,hippostd:publishable)[(@hippo:paths=‘ed307dfc-5774-4ac7-9feb-79b57e058bb2’) and ((@hippo:availability = ‘preview’ or (@hippo:availability = ‘live’)) and (@ftcore:date_valid_until____day >= xs:dateTime(‘2020-06-07T00:00:00.000+05:30’)))]/… order by @hippostdpubwf:lastModificationDate descending

Documents :

Coremetadata"

Hi,
The fact that query includes hippostd:publishable , hippo:availability etc. makes sense because you’re looking for documents, not for compounds.

The query has: and (@ftcore:date_valid_until____day >= ...
but you should aim to have something like and (ftcore:CoreMetadata/@ftcore:date_valid_until >= ...

Again, if that doesn’t work, use a derived data function to copy the property to document level so you can use that.

HTH
Jeroen

Thanks Jeroen for all your responce.
trick the query with small correction by adding star and its worked

Good to hear!
Regards, Jeroen