Exact match for a multiple value facet


(Kevin Disneur) #1

Hello,

We're moving our search and faceting solution for our e-commerce
website from SOLR to elastic search, we're thrilled so far by the
speed of the solution but we're encountering a problem for which we
couldn't find a solution in the documentation or on the archives of
this mailing list.

We have a list of products for which we store multiple values:
id, color_id, color_title, size_ids, size_titles

We're using color_title and size_titles as Facets. color_title is a
unique value facet and size_titles is multiple.
Titles are used for sorting and displaying, so we need to be able to
match ids with values.

For the unique value facet (color) we used a script :

{
"query": {
"match_all": {}
},
"facets": {
"color_title": {
"terms": {
"field": "color_title",
"script" : "term + ';' + _source.color_id"
}
}
}
}

We tried to use the same principle for sizes but it doesn't work.

For a same term, we get multiple results corresponding to the list of
all the size_ids containing our size_title :

size_title; [size_ids]
47 ;[18, 26, 14, 15, 16, 17, 19, 20]
47 ;[21, 14, 15, 22, 16, 23, 24, 19, 25, 18, 26, 13, 20]
47 ;[27, 16, 17, 25, 52, 26, 14]
48 ;[14, 15, 16, 23, 17, 19, 20, 18, 26, 69]

Is there any way to get the exact size_id matching our size_title for
a multiple value facet?

Thanks in advance for your help and the good work you put into this
project.


(Shay Banon) #2

First, regarding the first facet, prefer not to use _source.., since this will cause loading and parsing source for each document matching the query. Prefer doc.

Regarding the second facet, multi values are fine, but getting a "relationship" between multi values is problematic since its not maintained if they exist in the same doc (i.e size_ids : [1, 2], size_titles : ["test", "value"]). I didn't full understand why you need a facet that combines the two, why not just use size_ids?

On Tuesday, February 21, 2012 at 12:15 PM, Kevin Disneur wrote:

Hello,

We're moving our search and faceting solution for our e-commerce
website from SOLR to elastic search, we're thrilled so far by the
speed of the solution but we're encountering a problem for which we
couldn't find a solution in the documentation or on the archives of
this mailing list.

We have a list of products for which we store multiple values:
id, color_id, color_title, size_ids, size_titles

We're using color_title and size_titles as Facets. color_title is a
unique value facet and size_titles is multiple.
Titles are used for sorting and displaying, so we need to be able to
match ids with values.

For the unique value facet (color) we used a script :

{
"query": {
"match_all": {}
},
"facets": {
"color_title": {
"terms": {
"field": "color_title",
"script" : "term + ';' + _source.color_id"
}
}
}
}

We tried to use the same principle for sizes but it doesn't work.

For a same term, we get multiple results corresponding to the list of
all the size_ids containing our size_title :

size_title; [size_ids]
47 ;[18, 26, 14, 15, 16, 17, 19, 20]
47 ;[21, 14, 15, 22, 16, 23, 24, 19, 25, 18, 26, 13, 20]
47 ;[27, 16, 17, 25, 52, 26, 14]
48 ;[14, 15, 16, 23, 17, 19, 20, 18, 26, 69]

Is there any way to get the exact size_id matching our size_title for
a multiple value facet?

Thanks in advance for your help and the good work you put into this
project.


(system) #3