Facet filter on nested facets

Hello,

We are using elasticsearch to store vehicles.

Vehicles are defined (among other things) by a list of criteria (ex :
color, fuel, gearbox and almost 80 others). Only a few of them are actually
used for search queries, the others are only here for display.

A criteria is identified by a categoryCode (ex : COLOR) ans a valueCode (ex
: RED).

We map this criteria as a nested type. The mapping looks like this :

{
"settings" : {
...
},
"mappings":{
"vehicle":{
"properties":{
...
"criteria": {
"type":"nested",
"properties":{
"groupCode":{
"type":"string" , "index" : "not_analyzed"
},
"categoryCode":{
"type":"string" , "index" : "not_analyzed"
},
"label":{
"type":"string"
},
"valueCode":{
"type":"string", "index" : "not_analyzed"
},
}
}
}
}
}
}

We can already search vehicles through several criteria and getting facets
from it :

{
"from": 0,
"size": 20,
"facets": {
"COLOR": {
"terms": {
"field": "criteria.valueCode",
"size": 20
},
"facet_filter": {
"bool": {
"must": {
"terms": {
"criteria.categoryCode": [
"COLOR"
]
}
}
}
},
"nested": "criteria",
}
}
}

With this request we can get with the facet COLOR, the different value
codes and update options in our search engine :
COLOR: {

  • _type: terms
  • missing: 0
  • total: 179
  • other: 0
  • terms: [
    • {
      • term: RED
      • count: 92
        }
    • {
      • term: BLUE
      • count: 82
        }
    • {
      • term: GREEN
      • count: 2
        }
    • {
      • term: YELLOW
      • count: 2
        }
    • {
      • term: BLACK
      • count: 1
        }
        ]

}

What we would like to achieve is that if we select the red color for
example to be able to retrieve other colors as long as an other criteria
(such as fuel) forbids us to do that.

We can already achieve that with non nested fields with facet filters by
changing the scope of the facet and excluding the current field from the
facet filter but with nested fields, it just returns empty facets.

Anyone has an idea on how we can get this result with nested fields ?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

}

What we would like to achieve is that if we select the red color for
example to be able to retrieve other colors as long as an other
criteria (such as fuel) forbids us to do that.

We can already achieve that with non nested fields with facet filters
by changing the scope of the facet and excluding the current field
from the facet filter but with nested fields, it just returns empty
facets.

Yes, scopes on nested docs were buggy, and in fact filter scopes have
been removed in v0.90+

Instead, include the necessary nested filters within the facet_filter
itself

clint

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.