4

I have solr field stored as -

record1 --> colorDimension : "Purple|91"
record2 --> colorDimension : "Purple|974|91"
record3 --> colorDimension : "Purple|974"

I need to facet on this colorDimension Field in a way such that term contains "Purple" and number "91".

The result I am targeting is -

Purple|91 = 2

I was looking out for facet.contains but did not get any examples that uses regular expressions.

E_net4
  • 27,810
  • 13
  • 101
  • 139

3 Answers3

1

You should expand these while indexing, so that you have a token for Purple|91 and Purple|974 separately. Faceting is quick because it can count tokens, without having to run a regex against each one to find the actual value.

You'll probably have to do this in your code, since I don't think you can make the pattern regex tokenizer spit out multiple tokens for a given prefix / group.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
0

Try using this pattern:

Purple\|(?:\d+\|)*91(?:\||$)

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
0

If you actually need to make use of regular expressions, there is a parameter facet.matches, which can be used to specify a regular expression to restrict the facet results

Jan Rasehorn
  • 311
  • 2
  • 6