3
votes

How to search for a word in facet query in solr (or in other words how to use wildcard in search by facet)
for example if i have facet filed MyField and it has the following values:

  1. ValX ValY
  2. ValX
  3. ValZ ValW
  4. ValX ValV
  5. ValA ValX
  6. ValA ValB

now if i search for fq=MyField:ValX, i will get the second record only. how can i search for ValX and get the 1st, 2nd, 4th and 5th records?
you know fq=MyField:*ValX* is not allowed and fq=MyField:ValX* will not return the 5th record.
any idea is highly appreciated.

2
Is this not supported by SOLR fq=MyField:*ValX*? If so how it can be achieved ? i want to filter based on a matching text like *text*. ThanksPranay

2 Answers

2
votes

How is MyField defined in schema.xml? Looks to me as if it isn't tokenized, like for instance with

type="string"

With

type="text"

the field value is tokenized so that

fq=MyField:valx

should match 1, 2, 4 and 5.

1
votes

Wildcard card on Facet Query should work.

As wildcard queries does not undergo any analysis, you can try fq=MyField:valx*

What you are trying is not filtering but rather searching.
Use a white space tokenizer with lower case filters and search q=MyField:valx and it would match the results. You can use prefix and wildcard queries with it as well.