Flowpack.SimpleSearch.ContentRepositoryAdaptor icon indicating copy to clipboard operation
Flowpack.SimpleSearch.ContentRepositoryAdaptor copied to clipboard

ExactMatch operator does not seem to work with properties containing multiple references

Open Duske opened this issue 11 years ago • 2 comments

Use Case: There's a nodetype "project" which has a property "categories" of type references. On the category page, i want to list all projects which have the current category in their reference property. Eel:

    ${Search.query(site).nodeType('My.Vendor:Project').exactMatch('category', node).execute()}

This works when there's only one category attached, if a 'project' has more than one category it will be not listed. Is there any possibility to check if the node is in the references list? Something like:

    ${Search.query(site).nodeType('My.Vendor:Project').isInProperty('category', node).execute()}

Duske avatar Nov 06 '14 12:11 Duske

I solved my problem by extending \Flowpack\SimpleSearch\ContentRepositoryAdaptor\Search\SqLiteQueryBuilder and adding the following function:

/**
     * adds an like query for references.
     *
     * @param $propertyName
     * @param $propertyValue
     * @return QueryBuilder
     */
    public function isInReferences($propertyName, $propertyValue) {
        $this->where[] = "(" . $propertyName . " LIKE '%" . $propertyValue->getIdentifier() . "%')";
        return $this;
    }

Duske avatar Nov 10 '14 12:11 Duske

Thanks, will check how we want to deal with this in the API and implement.

kitsunet avatar Dec 29 '14 19:12 kitsunet