json - solr: facet search multivalued field containing the same value multiple times -
i have field in solr document (in json):
somefield = [value1, value2, value3, value4,...];
i want know how many documents there containing each of values.
the facet search executing works there 1 problem: values represent hierarchy (denoted sequence) , same value appear on different levels in hierarchy (representing different entity).
e.g.
(in document1) somefield = [value1, value2, value3, value4]; (in document2) somefield = [value1, value3, value4, value5]; (in document3) somefield = [value1, value3, value3, value4];
so result should looke this:
value1 = 3 value2 = 1 value3 = 2 (level 2) value3 = 2 (level 3) value4 = 1 (level 3) value4 = 2 (level 4) value5 = 1
on inserting documents, can see inserting
value1, value3, value3
is inserted correctly (solr doesn't convert value1, value3
)
how can achieve faceting, i. e. make solr treat each level of somefiled
separately , not count value3
1 field?
you can't. token token when comes faceting.
you can use secondary field , add metainformation tokens when indexing (from own code), contain level token on.
so example above, you'd have second field named somefield_indexed content:
[1_value1, 2_value2, 3_value3, 4_value4] [1_value1, 2_value3, 3_value4, 4_value5] [1_value1, 2_value3, 3_value3, 4_value4]
the resulting facet be:
1_value1: 3 2_value2: 1 2_value3: 2 3_value3: 2 3_value4: 1 4_value4: 2 4_value5: 1
remove , including first _
when you're displaying contents facets. it'll allow filter on location of value (i.e. display documents have value3 in second location, using fq=somefield_indexed:2_value3
.
Comments
Post a Comment