Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use wildcard in solr facet query search

Tags:

solr

facet

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.

like image 371
Alaa Avatar asked Dec 22 '25 00:12

Alaa


2 Answers

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.

like image 57
Nils Weinander Avatar answered Dec 24 '25 10:12

Nils Weinander


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.

like image 29
Jayendra Avatar answered Dec 24 '25 10:12

Jayendra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!