Warm tip: This article is reproduced from stackoverflow.com, please click
solr solrj solr-search

Could Solr search contains wildcard in key?

发布于 2020-04-23 11:26:08

I have a json block saved as one document in solr,

{
    "internal":...
    "internet":...
    "interface":...
    "noise":...
    "noise":...
}

Could I seach as " inter*:* "? I want to find out all content with key start with "inter"

Unfortunately, I got parser error, is there any way that I could the search with a wildcard in the key?

Questioner
Neil
Viewed
66
MatsLindh 2020-02-08 17:11

No, not really. You'll have to do that as a copyField if providing a wildcard is important to you, in effect copying everything into a single field and then querying that field.

You can supply multiple fields through qf without specifying each field in the q parameter as long as you're using the edismax query handler - that's usually more flexible, but it will still require each field to be specified.

There's also a little known feature named "Field aliasing using per-field qf overrides" (I'm wasn't aware with it, at least). If I've parsed what I've been able to find from a few web searches correctly, you should be able to do f.i_fields.qf=internal internet interface&qf=i_fields. In effect creating an i_fields alias that refers to those three fields. You'll still have to give them explicitly.