Combining facet values


(Jasper van Wanrooy - Chatventure) #1

Hi,

I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?
I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.

The category mapping is defined as follows:
'category' => array(
'properties' => array(
'id' => array(
'type' => 'multi_field',
'fields' => array(
'id' => array('type' => 'long'),
'stringified' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name' => array(
'type' => 'multi_field',
'fields' => array(
'name' => array('type' => 'string', 'index' => 'analyzed', 'boost' => 2),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name_normalized' => array('type' => 'string', 'not_analyzed', 'boost' => 2),
'foreign_reference' => array('type' => 'string', 'index' => 'not_analyzed'),
'path' => array(
'type' => 'multi_field',
'fields' => array(
'path' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'path_normalized' => array(
'type' => 'multi_field',
'fields' => array(
'path_normalized' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
)
)
)

Thanks in advance!

Thanks, Jasper


(Shay Banon) #2

Term facet only works on a single field.
On Wednesday, May 18, 2011 at 3:31 PM, Jasper van Wanrooy - Chatventure wrote:

Hi,

I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?
I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.

The category mapping is defined as follows:
'category' => array(
'properties' => array(
'id' => array(
'type' => 'multi_field',
'fields' => array(
'id' => array('type' => 'long'),
'stringified' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name' => array(
'type' => 'multi_field',
'fields' => array(
'name' => array('type' => 'string', 'index' => 'analyzed', 'boost' => 2),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name_normalized' => array('type' => 'string', 'not_analyzed', 'boost' => 2),
'foreign_reference' => array('type' => 'string', 'index' => 'not_analyzed'),
'path' => array(
'type' => 'multi_field',
'fields' => array(
'path' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'path_normalized' => array(
'type' D> 'multi_field',
'fields' => array(
'path_normalized' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' D> array('type' => 'string', 'index' => 'not_analyzed')
)
)
)
)

Thanks in advance!

Thanks, Jasper


(Jasper van Wanrooy - Chatventure) #3

Thanks for your reply. I fixed the problem by combining the values with a script on the terms facet. Not ideal, but it works for me.

On donderdag 19 mei 2011 at 13:35, Shay Banon wrote:

Term facet only works on a single field.
On Wednesday, May 18, 2011 at 3:31 PM, Jasper van Wanrooy - Chatventure wrote:

Hi,

I'm creating a search functionality for a portal with products. Each product belongs to a single category. A category consists of a name, a normalized name and an id. How can I create a facet, which returns the three different fields?
I already tried to create three specific facets and combine them. However, this doesn't work out for the category id with the sorting.

The category mapping is defined as follows:
'category' => array(
'properties' => array(
'id' D> array(
'type' => 'multi_field',
'fields' => array(
'id' => array('type' => 'long'),
'stringified' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name' => array(
'type' => 'multi_field',
'fields' => array(
'name' => array('type' => 'string', 'index' => 'analyzed', 'boost' => 2),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'name_normalized' => array('type' => 'string', 'not_analyzed', 'boost' => 2),
'foreign_reference' => array('type' => 'string', 'index' => 'not_analyzed'),
'path' => array(
'type' => 'multi_field',
'fields' => array(
'path' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' => array('type' => 'string', 'index' => 'not_analyzed')
)
),
'path_normalized' => array(
'type' D> 'multi_field',
'fields' => array(
'path_normalized' => array('type' => 'string', 'index' => 'analyzed', 'index_analyzer' => 'path_index_analyzer', 'search_analyzer' => 'path_search_analyzer'),
'untouched' D> array('type' => 'string', 'index' => 'not_analyzed')
)
)
)
)

Thanks in advance!

Thanks, Jasper


(Karussell) #4

BTW: If you hit performance problems for your approach you could
combine them into one field while indexing


(system) #5