sherlock
sherlock copied to clipboard
How to map an object property with multiple fields
What would be the appropriate way to map an object with multiple properties? Thank you for your assistance.
$index->mappings(
Sherlock::mappingBuilder($this->indexType)->String()->field('title')->analyzer('snowball'),
Sherlock::mappingBuilder($this->indexType)->String()->field('description')->analyzer('snowball'),
Sherlock::mappingBuilder($this->indexType)->String()->field('status'),
Sherlock::mappingBuilder($this->indexType)->Number()->field('categoryId')->type('short'),
Sherlock::mappingBuilder($this->indexType)->Object()->field('data')->object(
Sherlock::mappingBuilder($this->indexType)->String()->field('field1'),
Sherlock::mappingBuilder($this->indexType)->String()->field('field2'),
Sherlock::mappingBuilder($this->indexType)->String()->field('field3'),
Sherlock::mappingBuilder($this->indexType)->String()->field('field4')
)
);
Array
(
[settings] => Array
(
)
[mappings] => Array
(
[post] => Array
(
[properties] => Array
(
[title] => Array
(
[type] => string
[analyzer] => snowball
)
[description] => Array
(
[type] => string
[analyzer] => snowball
)
[status] => Array
(
[type] => string
)
[categoryId] => Array
(
[type] => short
)
[data] => Array
(
[properties] => Array
(
[field1] => Array
(
[type] => string
)
)
[type] => object
)
)
)
)
)