silverstripe / silverstripe-search-service

A service-agnostic search module for Silverstripe CMS
BSD 3-Clause "New" or "Revised" License
5 stars 18 forks source link

Difficult to create arrays of items on an index #90

Closed blueo closed 5 months ago

blueo commented 1 year ago

Currently it is quite difficult to index an array that is created by a custom function. You can use the dot notation to index a relation eg Tags.ID and this will result in an array of IDs however you don't seem to be able return an array from a custom property and have it indexed eg

in search config

    App\MyObject:
          fields:
            some_field:
              property: getMyArrayOfThings
public function getMyArrayOfThings(): array
{
   return // do something that returns an array
}

this would be really useful for creating custom indexes and I think quite intuitive - eg returning an array should create an array on the index. Maybe I'm missing something here so open to correction on how this works.

lukereative commented 6 months ago

I've implemented a change which allows this (at least with Elastic) in https://github.com/silverstripe/silverstripe-search-service/pull/97

blueo commented 5 months ago

fixed by #97