Search code examples
solrfacet

use wildcard in solr facet query search


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.


Solution

  • 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.