solrsolrjsolr-search

Could Solr search contains wildcard in key?


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?


Solution

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