We consider a corpus of cooking recipes where you have an ingredients
meta, which comes from a multivalued index field.
The problem is that this meta displays by default all the ingredients found in the
documents matching your queries, and not only the relevant ingredients. You may thus get
extra-long hits with metas containing hundreds of worthless values.
If we search for “curry AND paprika AND chicken”
, what we expect is to see
these 3 ingredients, as values of the ingredients
meta.
If we want to display at least these 3 ingredients, and then possibly a few other
ingredients retrieved randomly, we can for example, define a Value selection on the
ingredients
meta, with Min. values to
5
and Max. values to 5
. The
ingredients meta displays: curry, paprika and chicken and 2 other ingredient values in the
order they are retrieved from the document. For example, your meta may display as follows:
ingredients: curry, cardamon, paprika, coriander, chicken
If we want to display matching values only, we must set Min. values
to 0
. We get: ingredients: curry
,
paprika
, chicken
in the order they are retrieved from the
document.
If we want to display 3 matching values, and at least 2 values (whether matching or not),
we set Min. values to 2
and Max.
values to 3
. We get:
-
ingredients: cardamom, salt
– if the document contains ingredient
values cardamom
, salt
, pepper
; since
we set it to keep a minimum of 2 values whether matching or not.
-
ingredients: cardamom, chicken
– if the document contains ingredient
values cardamom
, salt
, pepper
,
chicken
; since we set it to keep a minimum of 2 values whether
matching or not.
-
ingredients: chicken, paprika
– if the document contains ingredient
values cardamom
, chicken
, paprika
,
salt
, pepper
, since we keep in priority matching
values.
-
ingredients: chicken, paprika, curry
– if the document contains
ingredient values cardamom
, chicken
,
paprika
, curry
, salt
,
pepper
, since we can keep a maximum of 3 matching values.
-
ingredients: chicken, green curry, red curry
– if the document contains
ingredient values cardamom
, chicken
, green
curry
, red curry
, paprika
,
salt
, pepper
, since we can keep a maximum of 3
matching values and the order in which values are retrieved is taken into account.